Keep it simple!
-
Oh the joys of maintaining other people code under very strict SLA… Three (at least) layers of indirection between log4net and code + var keyword used everywhere compiler allows it… X|
-
Oh the joys of maintaining other people code under very strict SLA… Three (at least) layers of indirection between log4net and code + var keyword used everywhere compiler allows it… X|
NDA? BTW I like var!! ^^ If you don't I can see only 3 reason... 1. you haven't understand var 2. it is used in case where it is very hard to guess the type for a human without assistance 3. a good IDE will solve 2, but you don't have one! ;P
My programming get away... The Blog... DirectX for WinRT/C# since 2013! Taking over the world since 1371!
-
NDA? BTW I like var!! ^^ If you don't I can see only 3 reason... 1. you haven't understand var 2. it is used in case where it is very hard to guess the type for a human without assistance 3. a good IDE will solve 2, but you don't have one! ;P
My programming get away... The Blog... DirectX for WinRT/C# since 2013! Taking over the world since 1371!
I don't really like var, but it is unambiguously a good thing in one case only: when you are constructing an object and therefore have the type on the same line. There's no reason for
SomeLongTypeName<String, List<DomainObjectType>> myVariable = new SomeLongTypeName<String, List<DomainObjectType>>(...);
... when the type is right there. I don't like the common usage of var for Linq queries. It's never immediately obvious what the type of one of those is (it's
Queryable<T>
where T is the type of the last select clause, unless there's a call to First or Count or something similar ... working out the type requires a full reading of the whole query and hinting the query with what the type is is, imo, helpful in understanding it). -
I don't really like var, but it is unambiguously a good thing in one case only: when you are constructing an object and therefore have the type on the same line. There's no reason for
SomeLongTypeName<String, List<DomainObjectType>> myVariable = new SomeLongTypeName<String, List<DomainObjectType>>(...);
... when the type is right there. I don't like the common usage of var for Linq queries. It's never immediately obvious what the type of one of those is (it's
Queryable<T>
where T is the type of the last select clause, unless there's a call to First or Count or something similar ... working out the type requires a full reading of the whole query and hinting the query with what the type is is, imo, helpful in understanding it).Well, what if the result is anonymous type?! Or the guy changed his mind 17 times and got tired of typing the full type every time the 16th time? Just saying.. I understand you too! ;P In case you like a tip, maybe it's obvious, but how about skimming the query to the 'select ...' statement?
My programming get away... The Blog... DirectX for WinRT/C# since 2013! Taking over the world since 1371!
-
NDA? BTW I like var!! ^^ If you don't I can see only 3 reason... 1. you haven't understand var 2. it is used in case where it is very hard to guess the type for a human without assistance 3. a good IDE will solve 2, but you don't have one! ;P
My programming get away... The Blog... DirectX for WinRT/C# since 2013! Taking over the world since 1371!