Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Rephrase default value advice #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 11, 2017
Merged

Rephrase default value advice #34

merged 5 commits into from
Jan 11, 2017

Conversation

b0yfriend
Copy link
Contributor

@b0yfriend b0yfriend commented Jan 6, 2017

  • The original document asserted that "Short-circuiting is cleaner than conditionals"

  • ...only to override this assertion later with "Use default arguments instead of short circuiting."

  • This is a poor design-choice for an advisory document.

    • If you are going to say x > y,
    • then later say z > x,
    • you should just say z > x > y upfront.
    • Otherwise, many people might not see the z > x later on,
    • because many people will probably use this as a referential document. They probably won't read the entire work.

- The original document asserted that "Short-circuiting is cleaner than conditionals"
- ...only to override this assertion later with "Use default arguments instead of short circuiting."
- This is a poor design-choice for an advisory document.

        - If you are going to say x > y,
        - then later say z > x,
        - you should just say z > x > y upfront.
        - Otherwise, many people might not see the z > x later on,
        - because many people will probably use this as a referential document. They probably won't read the entire work.
}
```

**Good**:
**Better:**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for more contributions!

I agree with you in principle. It does seem to me that people are going to read this non-linearly. I do give advice in a linear way of increasing cleanliness -- see the Concurrency section. If we set the precedent here, that would need to be fixed.

As for your solution, this is looking almost perfect. I don't want to change the format of this project though, so let's avoid having a Better clause. Can we just have Good/Bad?

- This commit concerns the document's comparison of 3 approaches to default values.
  - Conditionals
  - Short-Circuiting
  - Default Arguments

- In my original pull request, I ordered these from bad to best:
  - Conditionals (Bad)
  - Short-Circuiting (Better)
  - Default Arguments (Best)

- In this commit, I am rephrasing the **Bad/Better/Best** ordering scheme to **Bad/Bad/Good** because:
  - The rest of the document uses the **Bad/Good** format.
  - We should use *consistent language* throughout the document.
@b0yfriend
Copy link
Contributor Author

I addressed your request. How does that look now?

Oh, and a big thanks for adapting Clean Code to JavaScript + being considerate to all the pull requests!

@ryanmcdermott
Copy link
Owner

That's almost there! I'm sorry I wasn't very clear with my thoughts. Can you have just one Bad example and one Good example? Thanks!

-The section, "Use default arguments instead of short circuiting or conditionals"
originally had 2 "bad examples" and 1 "good example."

- This commit lowers the "bad examples" count from 2 -> 1.

  - The 1st "bad example" demonstrated the "conditionals" approach to default values.
  - The 2nd "bad example" demonstrated the "short-circuit" approach to default values.
  - I decided to only show the "short-circuit" approach as the 1 bad example, since that's
    what most people would use traditionally in ES5.
  - Few people actually use the "conditionals" approach, so I felt that warning 
    against the "conditionals" approach was unnecessary.
@b0yfriend
Copy link
Contributor Author

I changed it to one Bad example and one Good example. How's that look now?

@ryanmcdermott ryanmcdermott merged commit 6794252 into ryanmcdermott:master Jan 11, 2017
@ryanmcdermott
Copy link
Owner

That's great, thank you for your hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants