In my last post, I queried the readers of this blog as to your preferences regarding the formatting of the simple if statement.
I pontificated on my preference for the one-line format for
compactness, while the predilection of those that commented roundly
favored the standard four-line format, with the primary reasons – as
summed up succinctly by Scott – that it “[s]cans much easier without ambiguity.”
This got me thinking about other “one liners” - some based on
trivial formatting and some based on language constructs
- and whether people felt the same way towards them. Here
are some examples:
The getter/setter:
Is this ok?
Or do you strictly adhere to this:
Quick aside…Eric Gunnerson has an interesting discussion going about whether code like either of the above should be used in general.
The tertiary:
Do you sprinkle these in occasionally or religiously avoid these beasts?
Closures (new):
Will you use these time/space-savers in C# 2.0?
Or better yet, using lambda expressions in C# 3.0?
I, personally, have much love for these, but I could see arguments
as to scan-ability and/or ambiguity. So, if you have just cause as to
why I should not be married to them, speak now, or forever hold your
peace…