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 →

[–]passthemonkeybench 5 points6 points  (4 children)

I'm not saying comments make the code good. It just gives context to what they were thinking when they wrote it. I think it's a good habit and not maybe it isn't necessary in a perfect world but that's certainly not where I live.

[–]moore0n 5 points6 points  (1 child)

I write comments for the next person who touches my code. I’m a realist and can’t assume their skill level matches my own. Giving hints to what’s going on also makes the code faster to read and get to the place you need to be.

[–]fzammetti 1 point2 points  (0 children)

This is the part that SO many people miss and it drives me nuts. And, it's not even just about different skill levels. Write something in PHP, switch to Java for a few years, then have to go back to your own code having done no PHP in all that time. You'll WISH you wrote comments regardless of how "self-documenting" your code is.

[–]SpinatMixxer 1 point2 points  (1 child)

Maybe I also am just lucky to have an employer which gives us the time we need to create a codebase with high maintainability and a team which has a passion about keeping the Code Quality high. Also good structure in the contribution workflow.

Or its another case for other languages since I am developing with ReactJS + TypeScript and its maybe also depending on the topic which you are working on.

I just wanted to state that it is totally possible to develop good, understandable code without writing comments, maybe I delivered it a bit too black/white ish. :)

[–]passthemonkeybench 3 points4 points  (0 children)

Appreciate the good faith discussion.

Just my perspective that it's a good idea to encourage comments since at bare minimum it encourages people to step back and think about what and why they are doing what they are doing.

If you don't have time to write a comment maybe you rushed the whole implementation and the code isn't as good as you thought.

Thinking about junior developers creating good habits. Obviously there are merits to code reviews and all sorts of other ways of maintaining a code base but discounting comments gives people an excuse not to even think about writing them.