Can you comment code too much?

Can you comment code too much?

Over-commented code is often more difficult to understand than code without comments. Little notes back and forth from all the different maintainers of a project can often get cluttered. You spend more time reading the comments than you do the actual code.

How much commenting should code have?

A good goal is to have 1 comment for every 1-4 lines of code. Be sure to not only document what your code is doing, but, as you begin writing more advanced code, you should document what was intentionally left out, optimized away, tried and discarded, etc – basically, any design decision you make.

Is Commenting code 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.

READ ALSO:   What should be included in a recommendation letter?

How often should you comment your code?

Usually for every 10 lines of code I put in a minimum of 5 lines of comments. Comments do not include pseudo code, work of art or commented code(code no longer in use). The guidance usually is 75\% of code should be comments but sometimes I think it is a bit much. However, more the meaningful comments the better.

Should code be commented?

Good comments compliment your code, while bad ones pull readers away from the main points. Before putting any comments, ask yourself whether it would serve any purposes rather than distract people from comprehending your program. Good codes have rhythm while mediocre codes have a lot of pauses.

Should every function have a comment?

Commenting out a function is always a good choice in my opinion. First and foremost you can actually understand what the function does without having to look deep into the code. This way your code will be easier to understand for other people.

How do you comment effectively in code?

13 Tips to Comment Your Code

  1. Comment each level. Comment each code block, using a uniform approach for each level.
  2. Use paragraph comments.
  3. Align comments in consecutive lines.
  4. Don’t insult the reader’s intelligence.
  5. Be polite.
  6. Get to the point.
  7. Use a consistent style.
  8. Use special tags for internal use.
READ ALSO:   How does car mass affect braking distance?

Is it good to comment your code?

Commenting involves placing Human Readable Descriptions inside of computer programs detailing what the Code is doing. Proper use of commenting can make code maintenance much easier, as well as helping make finding bugs faster. Further, commenting is very important when writing functions that other people will use.

Should I leave comments in code?

Why you shouldn’t comment your code?

It’s better to have no comments than misleading comments. They set expectations that are never fulfilled, they set up some ground rules which are never required to be followed. Comments are not responsible for explaining your badly written code. We write modules which we know are complex, we know they are a mess.

Do I need to comment every line of code?

You should write a comment on every line of code.

Are comments in code necessary?

Should every single line of code have its own comment?

In these worlds, a coding standard that calls for that every single line of code to have its own comment is not the right answer. Neither is forgoing comments. OTOH, making comments subject to code review is exactly the right kind of standard for critical software. It makes for more reviewable and maintainable code, but this comes at a cost.

READ ALSO:   Why do apps I use keep showing the cloud on my iPhone?

Is it bad programming if you comment too much?

And, as a general rule, commenting too much can be a symptom of bad programming. Categorically defining a method or process as a “code smell” is a “zealotry smell”. The term is becoming the new “considered harmful”. Please remember that all of these sort of things are supposed to be guidelines.

Is there such a thing as too much code smell?

Don’t forget that you have to maintain and keep in sync also comments… outdated or wrong comments can be a terrible pain! And, as a general rule, commenting too much can be a symptom of bad programming. Categorically defining a method or process as a “code smell” is a “zealotry smell”. The term is becoming the new “considered harmful”.

How do I remove comments from my code?

Consider a comment for every line, sequence, statement, section, structure, function, method, class, package, component, of code. Next consider renaming and simplifying to eliminate any need for that comment so you can delete it. Check in while comments are rare. Repeat until deadline.