Scripting News: 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:

      • Courier
      • .98em;
      • 110%
      • true
  • if condition {
    • code;
    • }

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.

Advertisements

About Dave Winer

Dave Winer, 54, pioneered the development of weblogs, syndication (RSS), podcasting, outlining, and web content management software; former contributing editor at Wired Magazine, research fellow at Harvard Law School, entrepreneur, and investor in web media companies. A native New Yorker, he received a Master's in Computer Science from the University of Wisconsin, a Bachelor's in Mathematics from Tulane University and currently lives in Berkeley, California.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s