Fully Qualified Named – A Matter of Preference

More often than not (depending upon context and teams) I preferto fully qualify references, particularly in cases wherethere are any possibilites of collisions now or inthe future (e.g. a lot of vaguely named data and business entitiesfall in this category, with nondescript names that could easilyapply elsewhere). This just seems like good defensive programming,and yields code that isn’t fragile. It won’t shatter ifsomeone adds a class to your namespace (or any other namespace thatyou’re blindly using) that collides with a class in anothernamespace. For precisely the same reason I often preface instancereferences with this.

In this preference I am more of an exception than the rule,however – most prefer to add a using atop their namespace,and simply rely upon the compiler to sort things out. The premisebeing that the fewer characters exist in the code, the cleanerand more maintainable it is: If you can add a usingSystem.Data.SqlClient to your file, then that namespace shouldnever appear again. There is definitely a lot of validity tothat position as well.

(Of course with something like the “CodeML” I described earlier,the XML would store the fully-qualified names, and developers canchoose whether to display the qualified or unqualified names basedupon their own preferences. It’s just a display issue)