Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

When I hear "aligning parameters", I think more of the difference between this:

  someFunction(firstParam, secondParam,
    thirdParam, fourthParam);
And this:

  someFunction(firstParam, secondParam,
               thirdParam, fourthParam);
I've always found the second much easier to read, especially when there are multiple levels of nested expressions, and it's a style that has been encouraged on every project I've worked on.

I agree that aligning '=' is actively harmful in the example you give, and that it's harmful in most situations where it's used. I've encountered very rare instances where it's helpful, though. Sometimes you have a sequence of values defined by expressions that follow a pattern:

  enum someEnum {
    FIRST = BASE + MASK & (1 << 0),
    SECOND_VALUE = BASE + MASK & (1 << 1),
    TH = BASE + MASK & (1 << 2)
  }
Aligning the expressions can make it more clear what the pattern is and how it differs from value to value:

  enum someEnum {
    FIRST        = BASE + MASK & (1 << 0),
    SECOND_VALUE = BASE + MASK & (1 << 1),
    TH           = BASE + MASK & (1 << 2)
  }
Often there are other ways to handle the issue, such as hiding the expression behind a macro or a function call; when that's more readable, that's the way to go. But in cases where writing the expression explicitly ends up being more readable, I find alignment to generally be a win in this case.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: