Skip to content

Commit 471de2e

Browse files
authored
Merge pull request #378 from brentguf/comments
Comments
2 parents 713fe2d + cdf7aac commit 471de2e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

1-js/03-code-quality/03-comments/article.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ complex;
1818
code;
1919
```
2020

21-
But in a good code the amount of such "explanatory" comments should be minimal. Seriously, a code should be easy to understand without them.
21+
But in good code the amount of such "explanatory" comments should be minimal. Seriously, code should be easy to understand without them.
2222

2323
There's a great rule about that: "if the code is so unclear that it requires a comment, then maybe it should be rewritten instead".
2424

@@ -113,7 +113,7 @@ function addJuice(container) {
113113

114114
Once again, functions themselves tell what's going on. There's nothing to comment. And also the code structure is better when split. It's clear what every function does, what it takes and what it returns.
115115

116-
In reality, we can't totally evade "explanatory" comments. There are complex algorithms. And there are smart "tweaks" for purposes of optimization. But generally we should try to keep the code simple and self-descriptive.
116+
In reality, we can't totally avoid "explanatory" comments. There are complex algorithms. And there are smart "tweaks" for purposes of optimization. But generally we should try to keep the code simple and self-descriptive.
117117

118118
## Good comments
119119

@@ -146,7 +146,7 @@ Document a function usage
146146
Also, there are tools like [JSDoc 3](https://github.com/jsdoc3/jsdoc) that can generate HTML-documentation from the comments. You can read more information about JSDoc at <http://usejsdoc.org/>.
147147

148148
Why is the task solved this way?
149-
: What's written is important. But what's *not* written maybe even more important to understand what's going on. Why is the task solved exactly this way? The code gives no answer.
149+
: What's written is important. But what's *not* written may be even more important to understand what's going on. Why is the task solved exactly this way? The code gives no answer.
150150

151151
If there are many ways to solve the task, why this one? Especially when it's not the most obvious one.
152152

@@ -158,7 +158,7 @@ Why is the task solved this way?
158158
Comments that explain the solution are very important. They help to continue development the right way.
159159

160160
Any subtle features of the code? Where they are used?
161-
: If the code has anything subtle and counter-obvious, it's definitely worth commenting.
161+
: If the code has anything subtle and counter-intuitive, it's definitely worth commenting.
162162

163163
## Summary
164164

@@ -172,7 +172,7 @@ Good comments allow us to maintain the code well, come back to it after a delay
172172
- Function usage.
173173
- Important solutions, especially when not immediately obvious.
174174

175-
**Evade comments:**
175+
**Avoid comments:**
176176

177177
- That tell "how code works" and "what it does".
178178
- Put them only if it's impossible to make the code so simple and self-descriptive that it doesn't require those.

0 commit comments

Comments
 (0)