Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Personally, I don't write comments. I write self explanatory method names. Comments become unmaintainable


Regarding the relative usefulness of a well-named method vs an explanatory comment, I think it depends on the culture of refactoring for the codebase. If a codebase sees its code very regularly refactored, then comments can be downright dangerous/misleading while methods are easily renamed throughout. On the other hand, a well placed comment can tell you a lot of “why” or “how-to” that a method name / signature cannot.


Comments can get stale really fast but I probably write at least twice the amount of comments as code because that's how I reason about the function and intention of the code. Sometimes the code seems simple but the reason why it exists can be really complex.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: