Hacker News new | past | comments | ask | show | jobs | submit login

> Much better to leave a comment saying "there's a subtle but important thing going on here".

Sure, but don't let perfect be the enemy of the good. Well-meaning engineers frequently don't document their code at all. It's why I advocate programmers at least use descriptive variable names and function names; what I call "self-documenting code".

It still falls short of well-documented code but, as I say, gets you "good".




For sure, well-written code often doesn't need comments to explain itself; my point was that "there's an extra space here so you know this bit is important" is pretty much the opposite of that.


I do use whitespace (empty lines) to "group" parts of a function the way paragraphs group thoughts in prose. For a function it might be as simple as param-check, setup, loop, tear-down. But it makes it a little clearer that some lines of tightly-grouped code represent an "activity" (sub-activity?).


As an example, your own comment three above is split into three parts (quote and two sections of your own). Plus my comment here, split into two.

Code has its own flow and natural groupings just like human language, and adding spacing to match makes it easier to understand even though it is subtle.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: