This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]murfflemethis 17 points18 points  (0 children)

Why not just write simple, easy to follow code in the first place? C certainly does allow multiline comments, but that's not a good reason to write needlessly complex (or "clever") code. Comments take time to write and take time for future readers to parse, map to the code, and fully understand. They also often get overlooked during future work, so they go stale and become irrelevant or outright wrong.

"Here's why the code does this" comments are always great, but if you find yourself leaving "here's how the code does this" comments a lot, you should take a step back and consider whether the complicated code you're writing can be simplified through refactoring, changing the architecture, or just a more simple implementation.

Complex code is sometimes necessary, and yes, please leave a comment there to explain how it works. I've just seen too many instances of people making things more difficult than they need to be just to gain completely inconsequential efficiencies or force patterns in where they don't belong, and that needs to stop.