4 ms·
No, the reader must not need to read the function to understand how it works. The idea would be that the function names are so good that one does not need to r
by nercury 10y ago
No, the reader must not need to read the function to understand how it works.
The idea would be that the function names are so good that one does not need to read the function contents, right?
But some things are complicated and may not be expressible with the function name alone.
That's why people write comments. To help readers understand the code.
Let's say I am implementing some algorithm. I may mention the performance characteristics in the comment. Or I may let the readers dig into the code to find out what they are. Seriously, please don't follow "no comments" rule dogmatically.
- kyberias 10y agoNo. If I have a function and I need to understand _how_it works_, that is, how does it implement some algorithm, of course I have to read every single line of code to understand how it works! If the function is named "quicksort", for example, and I suspect it has a bug, I really have to read it to understand whether it implements the quicksort algorithm correctly.
- lisivka 10y agoGood luck with understanding of incorrect code of unknown algorithm.
- sqeaky 10y agoI don't think starting a comment off with "No" is an effective tactic to convey your point or change someone else' mind. It seems clear to me, as an impartial third party, that there are merits and drawbacks to both of your school's of thought on comments. "No" attempts to shutdown the discussion and makes it hard to discuss these.