The advantage of single-var over mult-var is that in single-var you are free to add, delete and reorder variables independently of each other. It is always the same. In multi-var there are at least 3 cases which you need to handle when editing one of the vars. Those are cases I don't need to be thinking of.
If typing var is too much work then you should reconsider your programming style and/or learn some basic typing. Speed of typing is rarely a bottle-neck for programmers.
Not to mention the readability problem that multi-var has once the initial var is scrolled out of view.
Advantage over typing the word var and a semi-colon vs swapping a semi-colon with a comma? Any linter will error bad code, so your argument of being bothered by a syntax issue is slim-to-none.
Typing is not my problem. Code duplication and readability is the problem. Consider 15 different non-initialized private variables for a constructor function. Are you really going to type var 15 times?
What about when you initialize all the variables at the beginning of a method. Oh look, another 4 or 5 var keywords.
If they were type signatures (int, short, double, etc.), it's totally different as each one has a lot of meaning. But writing the word var, over and over and over, just pollutes code.
3
u/sime Mar 27 '15
The advantage of single-var over mult-var is that in single-var you are free to add, delete and reorder variables independently of each other. It is always the same. In multi-var there are at least 3 cases which you need to handle when editing one of the vars. Those are cases I don't need to be thinking of.
If typing
varis too much work then you should reconsider your programming style and/or learn some basic typing. Speed of typing is rarely a bottle-neck for programmers.Not to mention the readability problem that multi-var has once the initial
varis scrolled out of view.