A shout out to Brent Simmons regarding his take on code formatting style.

Personally I tend to agree with Brent that opening braces at the end of lines is easier to read. Perhaps this comes from the fact that he and I both spent lots of time writing UserTalk code in Frontier’s outliner.

Typically code written in the outliner didn’t have curly braces at all – code blocks were defined by indentation, though occasionally we’d use braces on a single line:

Multi-line example:

Single-line example:

But when you take the same code and copy/paste it from the outliner into a text document (or save the script to a text file), you get this from the multi-line example above:

Note the left-brace at the end of the first and third line. (The same text could be pasted back into the outliner to get the braces-free, indented version.)

Another reason I like the brace at the end of the line is that when you collapse a block in Xcode, the whole block lands on a single line in the editor, instead of on two lines. Personally I find this a lot less distracting than having two lines for every collapsed block, and being an outliner guy, I use expand/collapse in Xcode quite a bit.

Anyway, just a thought…

Ps. I totally agree with Brent that consistency is more important than the specific style rules.

m4s0n501

Development