I have problem to find a good namespace design and class order.
Imagine we have the following namespace hierarchy:
MyCompany.Hardware
- ClassA
MyCompany.Hardware.DeviceType1
- ClassB : ClassA
MyCompany.Hardware.DeviceType2
- ClassC : ClassA
MyCompany.Hardware.Reader
- ReaderClassC : Reader
Questions:
-
Should I put the base classes always in the parent namespace? Or in the child namespace and the concret implementations in the parent?
-
Should the
ReaderClassCbe in a separate or in the same namespaceMyCompany.Hardware.DeviceType2? Or should I prefer the parent namespace for ‘fast’ access? -
Forget all the namespaces and put all into one (
MyCompany.Hardware)?
Hoppefully you understand what I try to get out. It would be great if you can tell me about your namespace design.
As usual it’s a matter of taste.
I prefer to use your fourth approach since it’s a little cleaner (for me). I mean, if I’m using a Reader then I depend on using that namespace.
Of course you can give a look to the Namespace Naming Guidelines and particularly: