Sun, July 29, 2007, 12:06 PM under Orcas
In my demos you will never find superfluous using
statements at the top of code files. When I am trying to explain some new API, I want it to be very clear what namespaces are being used. I have seen many other presenters that leave in there every namespace under the sun and it always annoys me. The other thing I try and do is remove references to assemblies that I am not using (for the same reasons). In fact, I used to do both of these even in real projects; even though there are zero performance implications for either, it just felt cleaner to me.
Now with VS2008 the manual process of removing namespaces is taken care for you. Simply right click in a code file and you see a new option as shown here:
Great! I am not so sure about sorting though. It sorts alphabetically and perhaps that is a good idea now that I think of it, but I am used to sorting my namespaces by length from shortest to longest so a nice triangle is visually formed (yes, I am weird, I know). More seriously, I usually just leave the last namespace I imported appear at the bottom of the list...
The sad thing is that this feature only takes care of using
statements and NOT of assembly references as hinted in my opening paragraph. The ironic thing is that while this is a new C#-only feature, in VB (even with VS2005) you can indeed remove unused assembly references from the project properties. If only the two teams talked to each other and both decided to implement the other's complementary feature...