some_var = foo()
another_var = bar()
or
some_var = foo()
another_var = bar()
Including changing the whitespace as lines are added or removed to keep them lined up. Does this really look good? Is it worth the mucking up of the diff?
some_var = foo()
another_var = bar()
or
some_var = foo()
another_var = bar()
Including changing the whitespace as lines are added or removed to keep them lined up. Does this really look good? Is it worth the mucking up of the diff?
From my time as VCS admin, darn few stylistic issues are worth mucking up the diff. We had a developer change names with his sex change procedure, and her new first name didn't have the same initial. She then changed her former initials to her new ones whenever she worked on a program, and that caused me a lot of annoyance.
No, unless there is some vertical relationship between the variables, such as:
some_var[ 1] = "foo";
some_var[100] = "bar";
But the cases are very rare that I do this, especially when I only have a few variables. This is a bit more common in SQL, where I might have the parameter name, type, and default value (three parts) in one line, but even there I try avoid it--it isn't worth the hassle.
@some_var varchar(25) = NULL
@another_var varchar(1000) = ''
@one_more int = 0
I don't think it's a good style because it makes it too hard to make changes (you have to do all the work of lining them up again), and for me it is perfectly readable without the extra whitespace.
What's especially annoying about this is that when you change the left part of a line that is longer than all the other lines, you need to line up all the other lines all over again.
Example:
some_var = foo()
another_var = bar()
Now I want to add a var called another_another_var
:
some_var = foo()
another_var = bar()
another_another_var = baz()
Now I have to line them up again:
some_var = foo()
another_var = bar()
another_another_var = baz()
Very annoying.
No.
While some find this style ascetically pleasing, modern IDEs with syntax highlighting make aligning variables in this manner a waste of time, including the time it takes to reformat them when refactoring or modifying code.
In addition I'm a firm believer in declaring variables as close to the scope where they are needed. Rarely does that result in a block of variable declarations that would even need to be aligned.
With Perl, you can just set your preferences and run perl-tidy over your code every now and then.
It gives the nicety of the aligned = 's, in the right contexts, without the worry to need to think about how best to align them and remember to do it yourself.
Also, whatever coding style you have used for your project, you should maintain it vehemently.
The more consistent and strictly enforced the style, the easier it will be to discover oddities and programming errors amongst your code.
Also, some enforcements on coding style reduce diff collision based problems in the long term by enforcing good line-breaking rules.
Styles like that cause the eye to travel vertically; however, the code should be reading horizontally. A coding style should complement what the eye does instead of fighting with it.
Also, in extreme cases it becomes hard to casually see which assignment goes where because of large gaps. It is something I see too often in header files.
...
some_important_number = 348273;
initial_message_prefix = "foo";
another_important_number = 348711;
max_bucket_sz = 456;
...
With dozens of these in a block, it becomes hard to read.