Basic coding style

sybrandy sybrandy at gmail.com
Wed Nov 24 07:07:11 PST 2010


> Seriously, I fail to see how braces one their own line help visually catching code structure (and it's not only me ;-)
>

For me, it really helps me make sure that I'm not missing a brace as I 
can see them line up visually.  It's easier to see the missing brace in 
code that looks like this:

if (condition)
{
    foo();
}

Than this:

if (condition) {
     foo();
}

Yes, this is a simplified case, but if you start multiple levels of 
nesting, it can be confusing.

Of course, a Erlang/Haskell/Python style indentation syntax does work, 
but then, IMHO, it works best if your functions are very small.  Of 
course, I've never done any Python development, however I have done 
Erlang and Haskell in the past and the fact that they really make it 
easier to write small functions helps a lot.

Smaller functions are better in all languages, but at least with code 
I've seen for Java and some D, methods can end up being fairly long.

Casey


More information about the Digitalmars-d mailing list