Dennis Forbes on Pragmatic Software Development   Subscribe to RSS


About the Author
Dennis Forbes is a Toronto-based software architect. While focused primarily on the .NET and SQL Server worlds, Dennis frequently ventures outside of this comfort zone into game development, Linux development, and image processing. He has been published in several industry magazines, has been quoted in the Wall Street Journal and has been interviewed by NPR.

He is a vice president and lead software architect at an innovative New York City hedge fund back-office services firm.

Dennis has been working on solutions for the financial, telecommunications, and power generation markets for over 13 years.


Recent Entries


The Feed Bag

 
Thursday, October 06 2005

More often than not (depending upon context and teams) I prefer to fully qualify references, particularly in cases where there are any possibilites of collisions now or in the future (e.g. a lot of vaguely named data and business entities fall in this category, with nondescript names that could easily apply elsewhere). This just seems like good defensive programming, and yields code that isn't fragile. It won't shatter if someone adds a class to your namespace (or any other namespace that you're blindly using) that collides with a class in another namespace. For precisely the same reason I often preface instance references 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 premise being that the fewer characters exist in the code, the cleaner and more maintainable it is: If you can add a using System.Data.SqlClient to your file, then that namespace should never appear again. There is definitely a lot of validity to that position as well.

(Of course with something like the "CodeML" I described earlier, the XML would store the fully-qualified names, and developers can choose whether to display the qualified or unqualified names based upon their own preferences. It's just a display issue)

Reader Comments

Add Comment

Name *:

Email Address:

(your email address is not displayed)
Website:

Comment *:


Dennis Forbes