4 ms·
From my experience there is a correlation between the amount of code comments and defects in the code. The more I see comments in the code base of a module, the
by kyberias 10y ago
From my experience there is a correlation between the amount of code comments and defects in the code. The more I see comments in the code base of a module, the more likely it doesn't have any (unit) tests and the more it has defects.
Yet this may just indicate that the code is complex and therefore required comments and contains bugs.
In any case, high comment density is a code smell.
- lisivka 10y agoLOL. Comments are not a part of the code. Good comments adds to readability, bad commenting style (e.g. enterprise style comments for everything) affects readability. Comments cannot add bugs to code. What you think about spaces?
- kyberias 10y ago> Good comments adds to readability I agree. I was talking about the _amount_ of comments. Extreme example: void foobar() { // iterate over the list foreach(var item in list) { // send it sender.send(item); } } I've seen a lot of comments like this. They don't add value. They distract. They must be removed. They also tell that the author didn't have a clear understanding why code comments should be written, so we may not trust his/her judgement in other programming decisions. The code is suspect. It's a code smell.
- lisivka 10y agoIt's looks like top-to-bottom style of development: first, algorithm is written in text, then implemented in code. Kind of literate programming. Sometimes it helps, sometimes it not. Usually, this style is used right after the school, by inexperienced programmers incapable to keep algorithm in the head in parallel to development, or when experienced developer does his first steps in a new language. Not a problem for me. Usually, I clear them out.