My OCD opinion is to always be as explicit as possible while understanding that sometimes you cannot be. HOWEVER, keep in mind that using var because you "have to" might be 'code smell' because you do not follow the advice in the first sentence elsewhere.
33 Replies - 9534 Views - Last Post: 14 November 2012 - 06:46 PM
#32
Re: To 'var' or not to 'var'?
Posted 29 October 2012 - 06:41 AM
Again, I don't think this fetish for the explicit is necessary. If we all were working with older tools, maybe. But with all the capability VS gives us to inspect static code, I believe we should spend our time writing efficient, clean, easily-refactorable, and non-redundant code. Var is a good option in that direction.
#33
Re: To 'var' or not to 'var'?
Posted 05 November 2012 - 01:50 PM
var when it doesn't break readability.
That's how I work.
I can see Curtis's expectation of an IDE, but I personally consider readability to be readable with out the IDE.
But see, that's just preference... and really, are we going to pull out the swords over that?
That's how I work.
I can see Curtis's expectation of an IDE, but I personally consider readability to be readable with out the IDE.
But see, that's just preference... and really, are we going to pull out the swords over that?
#34
Re: To 'var' or not to 'var'?
Posted 14 November 2012 - 06:46 PM
I'm not sure if this is ideal, but I'm using var a lot in-order to write less (and so I'm much more productive.. it has nothing to do with me being lazy.. uhh.. nope.. not at all), and also (and that's justified!) to repeat as less as possible. It's easier to change when you've got to change only once at the declaration, not to mention it's much more readable.
I won't use it in cases where I'm not explicitly allocating a new:
(Notice that the variable i is actually a decimal.
I also won't use it in cases where I never explicitly write the type I want. Random is a wonderful example:
I won't use it in cases where I'm not explicitly allocating a new:
var i = 23m;
(Notice that the variable i is actually a decimal.
I also won't use it in cases where I never explicitly write the type I want. Random is a wonderful example:
Random r = new Random(); var x = r.Next();
This post has been edited by pokiaka: 14 November 2012 - 06:48 PM
|
|

New Topic/Question
Reply



MultiQuote




|