I recommend the Google Style Guides for the programming language you are using. I abide to these rules and they usually lead to clean-looking code. There are somethings I add myself (like 2 blank lines between functions) but overall I really like the Google Style Guides.
The different style guides vary a bit per language, as these are put together by different engineers who devote all their time working in that language, so what they have written down is what they believe leads to clean-looking code. It seems that overall, the rule of thumb is to only use blank lines to distinguish code groups. Multiple consecutive blank lines are hardly ever encouraged. Here's some excerpts from these guides:
A single blank line appears:
- Between consecutive members (or initializers) of a class: fields, constructors,
methods, nested classes, static initializers, instance initializers.
- Exception: A blank line between two consecutive
fields (having no other code between them) is optional. Such blank lines are used as needed to
create logical groupings of fields.
- Within method bodies, as needed to create logical groupings of statements.
- Optionally before the first member or after the last member of the class (neither
encouraged nor discouraged).
- As required by other sections of this document (such as Section 3.3,
Multiple consecutive blank lines are permitted, but never required (or encouraged).
Two blank lines between top-level definitions, be they function or class definitions. One blank line between method definitions and between the class line and the first method. Use single blank lines as you judge appropriate within functions or methods.
Minimize use of vertical whitespace.
This is more a principle than a rule: don't use blank lines when you don't have to. In particular, don't put more than one or two blank lines between functions, resist starting functions with a blank line, don't end functions with a blank line, and be discriminating with your use of blank lines inside functions.
The basic principle is: The more code that fits on one screen, the easier it is to follow and understand the control flow of the program. Of course, readability can suffer from code being too dense as well as too spread out, so use your judgement. But in general, minimize use of vertical whitespace.
Some rules of thumb to help when blank lines may be useful:
- Blank lines at the beginning or end of a function very rarely help readability.
- Blank lines inside a chain of if-else blocks may well help readability
Blank lines before and after @interface, @implementation, and @end are optional. If your @interface declares instance variables, a blank line should come after the closing brace (}).
Unless an interface or implementation is very short, such as when declaring a handful of private methods or a bridge class, adding blank lines usually helps readability.
I only put the information here regarding vertical whitespace, but some of the guides also have info on horizontal whitespace and a lot more formatting information (comments, blocks, indentation, etc...)
And the project is open source so if you have any suggestions you could email one of the project owners.