# [.net] Class and namespace naming

## Recommended Posts

I'm trying to decide what to name my classes and namespaces, and it's working well at the moment. The thing I'm wondering about is what to name my "graphics device" class and its interface. At the moment it looks like this:
Engine.Graphics.IDevice
Engine.Graphics.GLDevice
Engine.Graphics.D3DDevice
But I'm going to add a "sound device" class at a later stage, and I would like it to be called *Device as well. Like this:
Engine.Sound.IDevice
Engine.Sound.FMODDevice
And so on. Will there be a problem with having two classed named the same? Should I name the classes IGraphicsDevice/ISoundDevice instead? If so, should I keep the Engine.Graphics/Engine.Sound namespaces? Thanks a lot in advance!

##### Share on other sites
You can have classes named the same in differnt namespaces. Just remember that when you add those namespaces to your project that if you use "using" then you will come into a naming collision. If you are using both in the same file you will need to make sure you use thier complete names including the namespace so the complier can tell which one you want.

I would suggest to the begining of your namespace you add your "name" to it. There are countless number of "Engine" namespaces, this will keep your as unique. Just a suggestion.

theTroll

##### Share on other sites
The recommended namespace convention to avoid clashes from Microsoft is:

<company>.(<product>|<technology<)[.<Feature>][.<subnamespace>]
(from Framework design guidelines book)

This helps avoid clashes and makes things consistent which is good if you ever intend others to use your API.

If you never intend for anyone else to use it then do whatever feels good.