Hacker News new | ask | show | jobs
by regularfry 4903 days ago
I do use vertical alignment, but that's not necessarily how I'd align the above lines. Assuming y and z are related, but x is not, I'd do them like this:

    int x
    int   y
    float z
I might add a blank line between x and y, too.

If you do vertical alignment such that it emphasises semantic relations, you avoid commits that change more than they should, and it also helps draw your eye to relationships between variables.

1 comments

I'll make exceptions myself if there is one declaration that is just way longer...

    int   x
    int   y
    float z
    MyReallyLongTypeHere foo;
Other than that, I tend to prefer having the variable names line up. Though doing mostly JS and C#, I can use var pretty much anywhere an assignment happens, even with null initialization.

    var foo = (sometype)null;
The bigger issue to me is comma first vs comma last... I find that comma first is easier to notice a missing/extra.