DEV Community

Discussion on: Why Good Code Needs Comments

Collapse
 
bernarddusablon profile image
Bernard Dusablon

For myself I use a module explanation (by file or folder).
It include Nature and origin of data
The goal of the process or features of this module
Restrictions (valid data ranges and type) and pitfalls,
I don't use Var, less possible, No Lamba, or the minimum possible.
and i don't use no meaning locals like simple letter except for a basic iterations.
I Rarely stall on my code like before trying to understand what i did last year for example...

Collapse
 
mxldevs profile image
MxL Devs

Thanks for the feedback. I like module-level comments as well, so if I see a folder with 10 files, I can go through each of them and quickly look at what purpose they might serve.

There are definitely a lot of language-specific syntaxes. Things that are considered "pythonic" for example might be quite unintuitive for someone that doesn't have a strong grasp of python, and they're spending more time trying to figure out what the code is doing.

If it's for performance reasons, comments are a good compromise because while I might not be able to understand how it works immediately, I can at least know why it's there and that it seems to do what it's supposed to do.