Quote:
Originally Posted by InfamousNoone
My point is, I don't see why you would even need to know what it returns. In this case, it's not like you're about to do anything with the connection other than invoke some method belonging to it. I mean at the end of the day I can see we disagree on this matter so I'll just leave at that, not everyone holds the same views as when to use var, we can at least agree on that :p
|
Indeed, we're looking at it from different angles though, alot of the problem with var is not to do with its use from a programming point of view, but from the point of view of team work and outside observers and users of the code.
Take this line on its own:
Code:
using(var conn = DBCore.GetNewConnection())
Tell me what type of database it is, what the type being returned is, what type of connection.
There are many issues with that line of course, DBCore offers no clues so the naming is pretty poor, so to an outside observer this line could mean pretty much anything. It potentially could be a socket connection to a core database server since we don't know the type.
Var has its uses like anything else, but its important to use it as intended.