Contents
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:
When do you need to remove clarification comments?
Clarification comments. Clarification comments are intended for anyone (including your future self) who may need to maintain, refactor, or extend your code. Often, a clarification comment is a code smell. It tells you that your code is too complex. You should strive to remove clarification comments and simplify the code instead because,…
When to leave a comment on a website?
But you SHOULD leave a comment warning others not to pursue some seemingly obvious “better solution,” if you’ve already tried and rejected it. And when you do, the comment should specify what solution you tried and why you decided against it.
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.
When to write funny comments to make up for bad code?
Don’t get me wrong, there are times — especially when you are slogging through a crushing workload — where injecting a bit of humor can be good for the soul. But when you write a funny comment to make up for bad code, it actually makes people less likely to refactor and fix the code later.
Which is an example of a bad comment?
Here’s an example of a bad — though very entertaining — clarification comment. Rather than decorating a slightly confusing statement with a clever rhyme — in amphibrach dimeter, no less — the author would have been far better off spending time on a function that makes the code itself easier to read and understand.
What are the different types of code comments?
For starters, there are really two different types of code comments. I call them documentation comments and clarification comments. Documentation comments are intended for anyone who is likely to consume your source code, but not likely to read through it.