int x = 12;
Resharper would have me use the var keyword here, per the rule "use 'var' keyword whenever possible". So according to the resharper rule, this line should be written as:
var x = 12;
To me, this is less readable than the previous version. Did I mean for x to be an int? Maybe I needed an int16, or possibly a uint64? Possibly I was mistaken altogether and needed a float. For me, I would like the opposite rule, "use 'var' keyword only when required".
This is a big debate in the C# world. More dicussion can be found at:
http://www.infoq.com/news/2008/05/CSharp-var
Personally, I come down on the side of minimal var usage. When I want to use var everywhere and implicit type inference, I will go write some JavaScript.
No comments:
Post a Comment