The Style Trap

Robert Graham,

A lot of companies spend a great deal of time, and politically gnashing of teeth among developers, in order to draft style guidelines. This is garbage — it truly does not matter where you put braces, for example. Experienced coders have to be accustomed to reading various styles anyway. Here’s what you should do. Start a program asking anybody who is interested to come in after work in order to draft a new set of style guidelines. Fire everyone who shows up — they are political animals who are likely deadweight anyway. Then just pick a style guideline at random, like the Linux kernel style doc or the WebKit style.

— Errata Security, How to code: lesson 27

I don’t know if I’m persuaded by this, for all that it sounds good. I would expect that some coding styles impose some discipline on coders, making it hard to make careless errors — and easier for others to spot them. Plus shared expectations do make code easier to read and understand.

Then again, maybe modern coding languages have other tools that can notice when you leave out a ) or a }, or mis-specify a variable. It’s been a long time since I actually had to write code anyone else would see, much less work with.

This entry was posted in Software. Bookmark the permalink.

3 Responses to The Style Trap

  1. Jim V says:

    The one aspect of style I consider essential is commenting. It is so much easier to come up to speed when reviewing something written years ago if comments are there to assist. I do like my CSS to be in order of appearance on a page and classes to be a single line, which I’m sure some would consider a quirk.

  2. Jamie says:

    I have my own pet peeves, but it isn’t worth arguing about. I agree that style-nazis are annoying, and tend to have other negative control-related traits. There are a few conventions that help catch specific types of errors that syntax highlighting doesn’t, like using

    if (‘constant’ == some_variable)

    That tends to make accidental assignment easier to spot. But most such advantages, I think, are pretty minimal.

    One actual problem that happens is when people get into formatting wars, intentional or not, reformatting things to fit their personal aesthetic preferences. This destroys much of the value of version control.

Comments are closed.