Open Mike: Brackets
Allman or K&R? This is Open Mike, a series of discussion posts to throw the cat amongst the pigeons. These posts are all about you — we want to hear your opinions, ideas, and thoughts. To kick things off, let’s talk about brackets. 1: Do you Cuddle? “Cuddling” braces means writing them like this: function [...]
View full post on Activetuts+

I cuddle, but I don’t cuddle } else {. I imaging the function or condition as the head and the end } as the tail.
I pad, because FlashDevelop auto-pads, and I like my code to be consistent.
I only nest if I’ve removed a boolean operator from the condition. Too many parens starts to make it look like LISP.
I agree with your second point: when I write my own code I do not pad, but when I am teaching students padding is essential in helping understand; specifically when students are far away from the screen or when they are looking back and forth between my code and theirs.
Sometimes I mix them when I want tighter code but most of the time I use Allman style. IMO it’s cleaner and it feels natural.
I use tight padding style just for because it looks cleaner to me. Mostly I use padding for variable declarations only for the purpose of nice formatting:
private var _someVar :String;
private var _anotherVar :Object;
public var publicVar :Number;
Also I sort the variables by their modifier and their data type. I usually do this after I finish with a class or when I’m in the mood for doing something else than coding.
As for nesting I use it only on complex conditions to make it easier to understand the order of the statements.
Allman
tight
don´t nest
I thinks a good reference for these questions is also: http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions
Cheers, Konstantin — I’m actually going to be asking about prefixes and capitalisation and so on in the coming weeks, so we can talk about those then
1. I cuddle, raised on C++ I think a lot of them cuddle.
2. I used to not pad, but as a flash development instructor I have found padding helps students read the code, so I have adjusted to padding (4th example) for that reason.
3. I don’t nest as in the example above, only when I want to show a clearly defined set of operation order. Such as, if( ( condition1 || condition2 ) && condition3 )
1. Allman Style
2. Tight
3. Nest
I mostly cuddle my braces,although i have been trying to move away from it.Hard to break a habit I’ve been using for so long though.I do sometimes find myself both cuddling and using Allman style in the same code,which is not a good thing ….for having consistent code.
I like the tight style for parentheses.
I’ve switched between cuddle and Allman style. At the moment I cuddle, but reading this article made me go back to Allman… I love the tip about commenting out the condition. Easy and quick.
And I am certainly a no-padding guy who finds nesting paranthesis in conditions a better read.
1. I like Allman style more, but I used to cuddle them when I was a beginner. My codes looked messier when I did it
2. I use tight style most of the time, but I don’t really pay any mind to this
3. I nest conditions in parenthesis only when it’s necessary, like in some math expression.
I would also add another questions like:
Do you use underscore in the names of private variables?
private var _someVar:Number;
or?
private var someVar:Number;
I use ks_ instead of underscore, which (I believe
) makes my codes more unique, lol
Or some other conventional stuff like using all caps for constant names.
I always do it, since I read Colin Moock’s essential actionscript 3