Contents
Is Commenting 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.
What is the correct way to insert comments in the code?
The single line comment is //. Everything from the // to the end of the line is a comment. To mark an entire region as a comment, use /* to start the comment and */ to end the comment. * This is a block comment.
Why do you put clarification comments in your code?
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, “good code is self-documenting.”
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.
What makes a comment thread a good one?
Before diving into designing and writing code, let’s break down what actually makes a good comment thread. A good comment thread will have the following characteristics: Comments are readable, and all the important data-points are visible to the user at a glance. This includes the author, number of votes, timestamp, and the content.
What should the structure of a comment be?
A comment by itself has a pretty simple structure. Here’s a skeleton of a single comment: So far, so good. Notice how the replies have an extra margin to the left. This is meant to satisfy the visual hierarchy (point #3 above). The markup for the above structure could look something like this: