DEV Community

Discussion on: The ONE book every developer MUST read!

Collapse
 
mattmoranjava profile image
Matt Moran

In my experience, comments should generally express the WHY (intent) of the code. That's necessary quite often because even the best written code can NEVER express its programmer's intentions. The WHAT is obvious, but the WHY is often inexpressible in machine logic.

Agreed. They can show clearly what they're doing, and possibly what they're trying to do (which is part of the intent story) but not why they're trying to do this. There should be some kind of design documentation around but that will get lost most likely, if the project survives a few decades. Probably not something for JavaDoc comments - you want those to be pretty black-box-ish, to say what inputs and outputs it consumes & produces - but nevertheless important.

Some comments have been hidden by the post's author - find out more