4 ms·
def doSomething( parameter1 , parameter2 , parameter3 ): pass How would you make all the punct
by philipov 10y ago
def doSomething( parameter1
, parameter2
, parameter3
):
pass
How would you make all the punctuation line up using tabs?
- chrismorgan 10y agoRather (assuming you’re dealing with Python), def do_something(parameter_1, parameter_2, parameter_3): pass
- scrollaway 10y agodef do_something( param1, param2, param3, param4 ): ... It's not that hard. Alignment is generally harmful - it's a maintenance burden which adds whitespace noise on diffs, which means more noise in code reviews. Not to mention how atrociously ugly it is when long variables/method names lead to 5+ lines with 60+ characters of indent for a single variable name per line.
- pyre 10y agoMost diff programs have an "ignore whitespace" option. "whitespace noise on diffs" is pretty much a solved problem. You can even add '?w=1' to a Github URL to turn on the feature.
- scrollaway 10y ago1. That's a band-aid. The characters have still been changed - the diff still "exists". 2. Those options are not perfect, they don't always work as expected 3. Those options are not turned on by default (because that would be INSANE) 4. Git's not the only VCS, much as I wish it were 5. Github's not the only Git web UI; that option is not available everywhere. It's not a "solved problem". It's an artificial problem, that gets solved when you start consistently stripping trailing whitespaces on save and not realigning everything all the time.
- pyre 10y ago> It's an artificial problem, that gets solved when you start consistently stripping trailing whitespaces on save and not realigning everything all the time. This is mostly solved via coding standards. If there are no coding standards people will "refactor" the coding style when they touch various pieces of code. If people were following a consistent style, then the alignment wouldn't be changing all of the time. Although I strongly agree with the trailing whitespace sentiment. The most egregious offender that I've found is Eclipse putting trailing spaces on blank lines to bring them to the indent level of the non-blank lines. Ugh.
- scrollaway 10y agoenum { NORMAL = 1 ABNORMAL = 2 IRREGULAR = 3 } Now if you're writing like this, what happens when you introduce "EXCEPTIONAL = 4"? You change 3 other unrelated lines. This is something that alignment causes, regardless of "coding standards". Hell, gofmt does that... It looks pretty (to some extent - with long names and lots of members it gets unreadable), but creates so much noise.
- oneeyedpigeon 10y agoYou don't, you use tabs for indentation and spaces for alignment.
- jasonkostempski 10y agoParent, you are the devil incarnate. Grandparent, you have bigger issues to resolve.
- dragonwriter 10y agoThe longer I've been programming, the more I think that alignment is ideally a presentational feature that a syntax-aware editor should do, not something that should be reflected in the source. But then tabs vs. spaces isn't an issue.