Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Long lines come most often in conditions of if- and while-blocks, mostly because there's no way to split them over multiple lines that isn't visually hideous.

But a condition can be easily split if it is assigned to a variable, and that variable then tested. And naming said variable well can make a comment explaining the condition redundant.



Yes, that's a great example, especially with deep nesting which forced indentation makes worse. But the solution feels like working against the grain, when a language should be working for human readability, not for workarounds to make a scripting language featureful.


One would argue that forcing long conditions to be split up, and intermediate steps named, is rather encouraging readability. ~


Yes, prefer a named variable if the logic gets long. If it is really long, consider introducing a function to calculate the predicate.




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

Search: