Code commenting is one of the best coding practices. However, if misused, it is bullshit! Whether bullshit or meaningful, it highly depends on how you’ve used comments in your code. However, good code is self-documenting, meaning that it doesn’t require comments. But this doesn’t mean you should never comment on your code. Commenting can reflect the good, the bad and the ugly in coding practice.
The Bad and Ugly Side of Commenting Your Code
- Documentation comments can make your code very “noisy” and difficult to read for those responsible in maintaining it. However, many code editors support code folding which allows comments to be collapsed so as to focus on the code.
- Clarification comments smell because they tell you that your code is too complex. The code should be made simple instead.
- Some developers could vent their frustration in code comments therefore resulting to comments that are depressing, cynical, dark or mean spirited.
- Commenting could go against the Don’t Repeat Yourself (DRY) principle.
For examples, click here
Comments
Post a Comment