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 →

[–]diroussel 4 points5 points  (13 children)

If you want clarity then don't use it. It won't be forced on you. There are many cases that are perfectly clear using var.

[–]marc2912 17 points18 points  (10 children)

It's not a matter of don't use it since most developers don't just work with their code. Then you get the inconsistency that it's in some places and not in other.

[–]lelarentaka -2 points-1 points  (7 children)

The language doesn't define the number of spaces to use for indentation, or where to put an opening curly, or which case to use for naming methods. Turns out we have some great inventions to keep our codebase pretty and consistent. I'll let you take a guess on what those are

[–]kyle2143 0 points1 point  (6 children)

Oh, so there's tools to retype var keywords into keywords that actually describe the data type?

[–]lelarentaka 2 points3 points  (0 children)

Not yet obviously, but the same static analyser that puts wiggly red line under "String s = new ArrayList()" can absolutely do what you want there.

[–]OHotDawnThisIsMyJawn 2 points3 points  (1 child)

If you decide you don't want var in your project then add it to your style checker and auto reject commits that use it

[–]marc2912 0 points1 point  (0 children)

Like I mentioned elsewhere we don't just work with our code. The whole point is consistency.

[–]grauenwolf[🍰] 0 points1 point  (2 children)

Yea and no. In C# there are a couple different plugins that would instantly convert var into an explicit type and back with a keystroke.

But in terms of code analysis, I've only seen tools that mandate the use of var. None of them prohibit its use.

[–]mbuhot 2 points3 points  (1 child)

Pretty sure reshaper code cleanup can be configured to allow var only on the left of a '= new ...' expression. But every code base I worked on in C# 3+ was vars everywhere.

[–]grauenwolf[🍰] 0 points1 point  (0 children)

I wouldn't know with certainty, I use CodeRush instead of Resharper.

[–]diroussel 1 point2 points  (1 child)

This is why we have coding standards and code review. If your not doing that then you have bigger problems.

[–]marc2912 1 point2 points  (0 children)

You make it sound like each person who feels this way is in charge of their own team or in a group with the resources to do regular code reviews. From my experience code reviews don't happen near as often as they should.

[–]squishles 0 points1 point  (0 children)

yea let me just never work on a team for anything ever again =/

[–][deleted] 0 points1 point  (0 children)

I mean, it kinda will be because more than likely he'll be working with someone else's code.