4 ms·
When the equal signs aren't aligned I first have to search where the symbol is on a given line to identify the left and right side. When the assignments are ali
by alpaca128 5y ago
When the equal signs aren't aligned I first have to search where the symbol is on a given line to identify the left and right side. When the assignments are aligned it's obvious at a glance.
I guess it's different between people, I personally find it noticeably slower and more difficult to read like that. Blank lines inbetween don't help because it's about horizontal alignment.
- josephg 5y agoI hear what you’re saying, but the horizontal alignment implies each line is doing a similar thing. That’s not the case here. Eg, the first line creates the ‘info’ variable and later lines use that to calculate derived variables. So order matters. Both approaches emphasise different narratives about the code. The aligned block style emphasises the similarity between the assignments. My space-between-lines style emphasises the difference between each block of code, as if each block is a paragraph it’s own separate intent. If the assignments were actually similar, I would find the other approach more compelling. Some sibling comments have given better examples where this makes sense. But for this code in particular, the assignments are more different than similar (in both goal and subject). I’d use spacing to make that difference obvious.