I came up with this rule by myself and found out that many people came to the same conclusion. I only use var when the right hand side expression is either a constructor call or a literal. Basically the type should be obvious by the statement.
Oh yes, it does tell me. It tells me I have an IEnumerable<Customer> rather than IEnumerable<CustomerDto> or PagedList<Customer> or something like this.
IDE tells you that. Documentation/go to definition tells you that. In most cases it's irrelevant anyway (obvious from use when reading or intellisense when working on it)and it's just noise.
And don't even try to argue "what about people who don't use an IDE" - sorry but if your editor doesn't support features mentioned above (and even Vim does) it's not fit for development with these languages - their highest value proposition is powerfull tool integration.
7
u/Eirenarch Mar 10 '16
I came up with this rule by myself and found out that many people came to the same conclusion. I only use var when the right hand side expression is either a constructor call or a literal. Basically the type should be obvious by the statement.
is not a good idea in my opinion