4. Commenting on obvious things
Most comments can be replaced with names of variables and functions. Before you write a comment, remember this.
For example, code like this:
You can replace it with this:
But sometimes you can only clarify the code with a comment. In that case, focus on the question: "WHY this code is needed," not "WHAT this code does. Here's an example of code where comments only clutter up the code:
Don't do that if you are a programmer. And if you are the employer of such programmers, fire them right now.
Last updated