DEV Community

Discussion on: You should write a comment on every line of code

Collapse
 
matthewbdaly profile image
Matthew Daly

I think comments are generally useful, but should be a last resort for explaining how something works.

DocBlock-style comments, for instance, are a poor substitute for actual parameter and return types. Where possible one should always set explicit parameter and return types in preference to setting them in a DocBlock, as these will be enforced by the language and so can't get outdated without explicitly breaking the response. For languages that don't support these, there are often other solutions, such as Flow in Javascript.

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