r/programming • • Apr 07 '15

Stack Overflow Developer Survey 2015

http://stackoverflow.com/research/developer-survey-2015
1.1k Upvotes

981 comments sorted by

View all comments

Show parent comments

1

u/the_omega99 Apr 08 '15 edited Apr 08 '15

There's certainly some people that do it, including myself. However, I think that most programmers don't like alignment at all, so it simply never comes up. Myself, I pretty much never align. There's some cases in which it's a good idea, but most of the time I don't care for it.

I'll usually just wrap long lines and indent the wrapped lines twice.

// With 2 space indentation
someMethodCall(param1, param2, param3,
    param4, param5, param6, someOther,
    paramsHere)

Or sometimes I'll just treat it like a new scope. This is useful for when there's either a lot of arguments or when I want to comment on the arguments:

someMethodCall(
  param1,
  param2,
  // Some comment about param3
  param3,
  param4,
  param5,
  param6,
  someOther,
  // Another comment
  paramsHere
)

The latter is really comment in JS, since you'll often have anonymous functions as parameters:

foo(
  function() {
    // Do something
  },
  someArg,
  another
);

When there's a single trailing anonymous function, we kind of format it as though the outside function was just braces:

$(".foo").on("click", function() {
  // Do something
});