I find the code more readable when the key words (key both syntactically and logically) are exposed as much as possible.
This is so much important to me that sometimes I resort to (IMO) quite unconventional thing.
Here's what it gets like:
if (condition) then begin
statement;
...
statement; end
else begin
...
end;
I admit, this can make it a bit less convenient to modify the code. It's just that I find the 'dangling' end
in the middle of an if
statement, and aligned same as the if
, somewhat confusing. If it is end
, it must be the final one (for the statement), otherwise I expect either else
or the beginning of the next statement at that position.
And I usually do not let it be when the then
block is compound, but the else
one is a single statement. This is never big deal with me to invert the condition and rearrange the blocks. Even more so since I am quite tight-fisted when it comes to wrapping a single statement with begin ... end
s. In my view and experience, abundant 'begin-end's are redundant 'begin-end's more often than not. Though I like it when a statement has an explicit ending keyword, so case
and repeat
are my all-time favourites. :)
One more thing about if
s (and while
s for that matter) is that in case of an umpteen-decker condition I tend to place then
(do
) on the next line and aligned on the statement's starting key word.
Like this:
if (some_long_conditional_expression) or
(some_other_long_conditional_expression) or
(some_even_longer_conditional_expression)
then
Exit;
Also, there are some other things already mentioned here which I am no foreigner to, like single-lined else if
s (when appropriate) or for ... do with ... do try
s (yeah, this again may have something to do with my tight-fisting nature mentioned above).
On the whole, I might probably be too much relying on code highlighting and indentation, especially the latter. Maybe if it were not for indentation, I would prefer always to single out the begin
s.
Another point: someone's formatting style may very likely be caused by their programming style. Like, some people hate very big routines and tend to factor whenever possible, while others prefer to concentrate on the code itself and never mind those several screen spanning compound blocks - I find these to be very different approaches, which can result in differrent formatting habits.