forked from ryanmcdermott/clean-code-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Update #1
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
Update #1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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.
This example should follow the guidelines about `const` vs `var` mentioned earlier
- 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.
-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.
Improve example "Function names should say what they do"
Rephrase default value advice
Use destructuring for explanatory variables
Use const instead of var
Fixed few examples
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.