I don't like this style either, but it's a style not a "bad habit."
I don't like this style either, but it's a style not a "bad habit."
It means constant readjustment and unnecessarily bloated diffs every time you change a function or variable name.
or the lovely
foo := a;
bar := b;
then a day later foo := a;
bar := b;
foobar := cd;
which also points to the problem that it lends itself to premature constant readjustment because a day later you have to move every thing again because as it turns out you really needed foobarlist as well. and each time you end up with a diff reporting that foo and bar (and then foobar) have changed too.It's making busy work for yourself and ruining the usefulness of code review tools.
ALSO alignment vs indentation is the whole reason we have to have the spaces vs tabs argument.
In it, they make a really good argument that humans simply shouldn't be doing this type of formatting work. Let the computers do it, clang-format can get it right every time in a fraction of the time a human can.
Pick whatever style you want, let the computers deal with it. I quite like this, now I just write a big long single line, hit a button and have it fixed for me.
It's not a bad habit if it looks better and doesn't involve any time investment.
Maybe no formatting characters should be allowed to be saved embedded in source code, and instead presentation filters should handle everything related to formatting, documentation, etc.
It might work..
Many GUI apps actually do that but unfortunately not your typical diff or git which insist in dealing with full lines only.
Somewhat related, if you're looking at a diff on GitHub and want to ignore whitespace, you can just tack on `?w=1` to the URL (https://github.com/blog/967-github-secrets).
javascript:(function()%7Bopen(location.href+'?w=1');%7D)();void(0);
Your variable example is the thing that peeves me most about golang, since gofmt insists on aligning consecutive variable names and types in that columnar fashion.
If needed allow your editor to have a task to reformat a code file on Open to apply formatting you desire vs the teams or project guidelines.
Indeed, that is one of the things I like about the indentation-only style. Unlike column alignment, you can use either spaces or tabs for indentation and the formatting still comes out fine.
Point well taken. But this was just a personal observation. If other people use column alignment, it would certainly be presumptuous of me to call it a "bad habit"!
For me, though, it was just that. I had no real reason for it other than having always done that way, and it was really starting to get in the way. So I was glad to be done with it.