3 ms·
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.
by int_19h 8y ago
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.
- goldfeld 8y agoYes, 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.
- int_19h 8y agoOne would argue that forcing long conditions to be split up, and intermediate steps named, is rather encouraging readability. ~
- jononor 8y agoYes, prefer a named variable if the logic gets long. If it is really long, consider introducing a function to calculate the predicate.