Breaking those long lines of code into smaller, grouped ones, with a clear consistency on where different types of elements are placed, is a small and efficient step towards improved readability.
Consider the code example below. There are two calls, five arguments, and three levels of nesting. However, that’s not what we get from the looks of it. We need to spend time visually parsing it and group the parts in different categories, not to mention that scrolling is required to even read the whole thing.
Note the form of this code, leaving the actual code aside. No clue, whatsoever.
From now on
We want to clearly see, without knowing the code, what is:
- A function call
- A function’s arguments
- Part of what
For that, we need to separate calls from arguments by placing the arguments in a new, indented line:
Where now the form of this code says it all, whatever the actual code is: