Hacker News new | ask | show | jobs
by InitialLastName 668 days ago
I feel like Raymond Hettinger's guideline that line complexity should be scaled to the limitations of human working memory, so should be limited to 7(+/-2) tokens [0], is a good compromise. This leaves some margin for nesting, but keeps in mind the capacity of the human brain to understand what a line is doing. If you can explain what the line of code is doing in a single sentence, you can probably also find a way to either name the variable sensibly or factor the code so that your step is a (well-named) method instead.

[0] https://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus...