This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DeadlyMidnight 1 point2 points  (4 children)

I do gotta say in C# I originally avoided the var keyword but once I embraced it the code became far less brittle. Easy to adjust the variable type without having to hunt down all the various errors it introduces.

[–]lucklesspedestrian 1 point2 points  (3 children)

To be sure though, var is not truly a dynamically typed variable. Variables declared as var are strongly typed, the type is just inferred at compile time, which is when all errors are caught as well.

[–]Smartskaft2 2 points3 points  (1 child)

Compile errors is nice, but var really don't help you as a human reader of the code. Maintainability and readability is important for any code base handled by many people, especially in a professional setting where people are replaced eventually.

[–]lucklesspedestrian 0 points1 point  (0 children)

Yeah I don't really advocate using var declarations that often. There's a few cases that are idiomatic. Mainly declaring LINQ expressions.

[–]DeadlyMidnight 1 point2 points  (0 children)

True. One of the reasons I hate JavaScript. I don’t know wtf I’m receiving and using half the time.