views:

113

answers:

4

I find now that I work in a mostly solo environment that I actually type fully qualified methods calls more and more, instead of make use of the using directive. Previously, I just stayed consistent with the most prominent coding practice on the team.

Personally, I find it easier to read verbose code at a glance, I type fast especially with autocompletion and I find myself using Google more often as my source of documentation, which a fully qualified name returns a much narrower results set. These are obviously very arbitrary reasons to prefer fully qualifying over using the using directive.

In this day and age of refactoring tools, is there a concrete reason why using the using directive is superior to fully qualified or vice versa, or is this purely a personal discretion issue like comment spacing? Finally, which do you prefer and why?

+3  A: 

Probably could call this subjective.

Where I work/What I prefer is to use using statements. It keeps the names/lines short enough, which just makes day to day life easier. Plus, you can just hover over something for the fully qualified name.

Finglas
A: 

I generally prefer using/imports for real code and fully qualified code for examples/etc.

lance
+1  A: 

I use usings whenever possible. The less there is to read, the less I have to parse:

System.Windows.Form form = new System.Windows.Form();

is just way more work than

var form = new Form();

Please note that this does require that your entire shop commits to not doing something silly, such as creating your own super-duper Form class which causes ambiguity.

Stu
Using var here makes this worse to read. If it was explicit, that would be better.
Finglas
I have a feeling var is going to go down in C# history as the most misused feature. It can create some very hard to understand code very easily.
Serapth
I strongly disagree. Reading from left-to-right, I should know by the time I hit '=' what the variable is and what it is called. I prefer to accomplish both by giving the variable a meaningful name and making it as short as possible. Also, consistently using var makes it easy to swoop through code and picking out the variable declarations at a glance.
Stu
A: 

Readability.

Think about yourself in 1 year, trying to read your code. You want it to be explicit and short and have only one point of information for each data (DRY principle).

Klaim