I was talking to one of my senior developers this week about curly braces. We’ve instituted our coding standard around The Elements of Java Style and we’re trying to hold to a strict interpretation. I even held a series of lunch and learns to help with adoption. This developer who has quite a few years of experience argued that:
“The curly braces on a new line really help me line up the nested blocks in conditionals. Without that I often miss a curly brace somewhere. Is this really something we need to do?”
At the end of the day I have trouble really believing wholeheartedly in no exception type standards, because so often I’ve seen them used to enforce bad ideas. By default all the Java coding standards assume you’ll have the curly braces starting on the same line because that is Sun’s standard. Defacto most java code out there follows this standard. At the end of the day this seems like a silly battle to fight the more I think about it.
Developers can get pretty religious about there preferences on this, but I’m planning on moving the placement of curly braces to the optional list, or at least let the developers pick a style on a per project basis. I know we’ll take a small hit in legibility since we’ll have two different styles, but the tradeoff is pretty minor.
I’ve seen a suggestion on a blog somewhere that a lot of this thrashing over coding conventions would disappear if the compiler enforced them. At that point there’s no argument anymore. I find that argument pretty convincing, but for now we still have a lot of options with conventions.
Never hurts to have your developers come back to you with strong arguments that some process isn’t helping them get the job done. Often they’re right.