2 ms·
I think this is one of those things that is more about wisdom than anything else. You get a sense of what to comment over time and experience. Typically follow
by wangchow 10y ago
I think this is one of those things that is more about wisdom than anything else. You get a sense of what to comment over time and experience.
Typically following language best-practices is ideal (pydoc, godoc, Javadoc, etc) so you can get easily-generated documentation for free. Following the standards will make any custom APIs consistent with the standard library API docs.
The most important thing though is to ask for peer review on the code. When you are writing code (just like regular language) it will make sense to you regardless of comments or proper variable names. Have someone else read it and tell you what the confusing bits are. If there is no one to do that because you're a lone wolf, then step away from the work for a couple days and play golf or something. Then come back, read the code, and ask if it could be more clear. Then either change variable names or add comments for clarification.