2 ms·
> I worked with some Rails folks a while back who were utterly convinced that comments were to be avoided because it meant your code was not clear. What this m
by randomdata 4y ago
> I worked with some Rails folks a while back who were utterly convinced that comments were to be avoided because it meant your code was not clear.
What this means is that if your Ruby code is clear it should read like natural language. Injecting subtitles into the middle of the expression
# I decided to phrase it this way because I was in a rush and it was the first thing that came out. With more time I could no doubt articulate this in a more communicative way, but for the sake of a random post on the internet I'm not terribly worried.
interrupts the flow when one is reading the code, which makes for a much less pleasant experience. Ruby may not be the only language that is like this, but it is relatively unique in this regard. Comments in other languages don't seem to cause the same interruption.
# That's all I've got. Time to clean up.
I'm not sure this means don't provide additional information to future readers that may be beneficial, but be discriminating in where you put it. Or do whatever you want. Who cares what someone else thinks?
- davidw 4y ago> should read like natural language The history of programming is full of that notion and it never really works out. See: COBOL, SQL, and so on. I think we can all agree that code that is easy to read is better, but sometimes the 'why' needs spelling out.
- randomdata 4y agoTotally agree. I even said so at the end. You would have noticed if the comments didn't get in the way. :)