Namespace = directory tree?

utilitaire

Regular
Joined
May 4, 2005
Messages
77
Up to now, all the classes I've created in my current project have been in a specific namespace, with the same directory logic tree. It is really easy to find a class when a project is structured. If I'm looking for the Tools.IO.email class, I know I can find it in the Tools.IO directory on my computer. Fine.

But Is there any good reason to organise the namespaces so that they dont fit the directory tree on your computer? For example: I have a namespace called «mycontrols». In this namespaces, I have, lets say, 20 different controls. When I want to use these controls in a webform, I just put the register tag with a single namespace:

<%@ Register TagPrefix="C" Assembly="Tools" Namespace="Tools.mycontrols" %>

After that, all my controls can be used with the «C» prefixe.

However, suppose I have many types of controls(validation, panel, etc.).I want all my controls to have the «C» prefixe in my code. I'd have to put them in the same namespace right? But it would be better to have all the validation controls in the same directory, just like I would like to have all the input controls in the same directory. Therefor, I'd have to make the namespace logic not fit the directory logic. Anyway, I just want to know if this is a good practice sometimes to organise the namespaces tree so that they dont fit the directory tree.

Thanks!
 
Back
Top