Contents
Why is commenting in code bad?
Consistently interrupted by redundant comments can create distractions. Comments are expected to make a connection between two flows of code, and not cut a single flow into fragments. Good comments compliment your code, while bad ones pull readers away from the main points.
Should I add comments to my code?
A handy rule of thumb is: a comment should only be added to answer a question that the code can’t. If you aren’t confused by what a piece of code is doing, but rather why it’s doing it at that moment, then a comment should be added.
Are code comments good or bad?
Commenting code is on the generally-recognized list of code smells. But unlike most of the others on the list, comments are not always bad. Generally speaking, you should strive to minimize comments and let the code speak for itself, but it is just as important to include comments when the code cannot.
How do you write a professional comment?
Top ten tips for writing a great comment
- Read the article.
- Respond to the article.
- Read the other comments.
- Make it clear who you’re replying to.
- Use the return key.
- Avoid sarcasm.
- Avoid unnecessary acronyms.
- Use facts.
When do you not need to put a comment in code?
Most coders would chuckle and move on, ignoring the code smell. There are also times when you come across a comment that is redundant. If the code is already simple and obvious, there’s no need to add a comment. Like, don’t do this nonsense:
Is it bad to put comments in JavaScript?
Some popular and well supported standards and tools include JSDoc for JavaScript, DocFx for dotNet, and JavaDoc for Java. The downside of these kinds of comments is that they can make your code very “noisy” and harder to read for anyone who is actively involved in maintaining it.
Is there a way to collapse comments in Visual Studio?
The good news is that most code editors support “code folding” which allows us to collapse the comments so we can focus on the code. Collapsing comments with code folding in Visual Studio Code. Clarification comments are intended for anyone (including your future self) who may need to maintain, refactor, or extend your code.
When to use header comments in source code?
Header comments are useful in source code for simple explanations of what to expect in that file. For instance, this is a script that comes with a game development engine called RPG Maker, and the core JS file that controls each game scene begins like this: Additionally, note that the version number is listed at the very top. Do this.