Writing code in an outliner, day 1

With Fargo out and with its evolving connection with JavaScript, I hope more people will be coding with an outliner.

I've been doing it pretty much exclusively for about 20 years, but I don't think I've ever written anything about the style considerations that come from using a structure-aware editor to code.

One of the big debates is where do the curly braces go?

For example:

if condition {



That's the way I do it.

I don't think the placement of the left brace is controversial. Why spend a line with a structural symbol if you don't have to.

But there's a long-standing argument about the right brace.

I always put it at the same level that the curly braces contain.

The advantage is this: When I want to move the block of code, I can just drag the headline with the condition in it. No need to select two lines.

That, and it feels conceptually right to me. If possible every construct should take up one line when collapsed. There are some examples where this isn't neat, in if-then-else, try-catch and switch statements. That's life, nothing's perfect.

Update: If you want to see what a less trivial bit of code looks like in an outliner, expand this headline. It's the JavaScript source for a Find command in the Fargo outliner.

<%reader ("https://dl.dropbox.com/s/qovudwpwgvt2pht/47bf3c76bd74a874d98880907d73d5df.opml")%>

Posted: Sat, 31 Aug 2013 17:14:27 GMT