Namespace convention help please

  • Thread starter Thread starter mrpubnight
  • Start date Start date
M

mrpubnight

Hi everyone, just hoping to get some opinions from those who have been
using/creating namespaces for a while.

Currently I have our namespace as follows:

CompanyName.Location.Client.Class

So for class DMRequest I may do something like this:

ABC.Base.DMRequestBase -> base class
ABC.AUS.JDHardware.DMRequest : which is meant to inherit from
ABC.Base.DMRequestBase.
ABC.USA.FDShoes.DMRequest : which is also meant to inherit from
ABC.Base.DMRequestBase.

Now I've read somewhere that one should use distinct names for
different classes (in this case DMRequest will inherit from
DMRequestBase but the implementation for each case may be different).
So that being the case should I use the following naming convention:

ABC.Base.DMRequestBase
ABC.AUS.JDHardware.AUSJDH_DMRequest
ABC.USA.FDShoes.USFDS_DMRequest

I know that the naming looks a little odd (I wouldn't necessarily use
that convention) but it is more just to make the point of the
difference between the two.

So ultimately I think my question is: Do I use the same class name and
have the namespace describe the implementation, or should I use new and
different class names given that they are in fact, different classes.

Thanks,
Frank.

PS: Follow up question: If I define classes at the base level (or at
the root of my namespace - i.e. ABC.ClassName) would it be more proper
to use the ABC.ClassName at a 'deeper' level in my namespace, i.e.
ABC.AUS.JDHardware, or should I create a new class in that level of the
namespace which effectively just inherits ABC.ClassName and may be
called ABC.AUS.JDHardware.ClassName. I hope this make some sense.
 
Personally, I wouldn't use your location in the namespace. I think it
is a piece of information that isn't really needed for the context.

Additionally, I don't know why you can't have two classes with the same
name. Look at the Control class. It exists in the following namespaces:

System.Windows.Forms
System.Web.UI
System.Windows.Controls (in Windows Presentation Foundation)

Finally, I would change your namespace definitions to conform to the
public naming conventions. Acroynms are not capitalized, and Pascal casing
is used, like so:

Abc.Base.DmRequestBase
Abc.JdHardware.DmRequest
....

An example in the framework is the HttpWebRequest class. Even though
HTTP is an acronym, it is Pascal-cased.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top