Namespace Rule of Thumb

I have not seen any rule of thumb at any reliable source but there are a few common preferences that I haven seen while working with most developers. There are a few things that help you make the namespaces.

  1. Domain of the class
  2. Is it a class or an interface (I have seen some developers prefer namespaces like ShopApp.Model.Interfaces ). Works really well if your interfaces are some service or data contract.
  3. Dont have namespaces that are too deep, 3 (.) is enough. More than that may get annoying.
  4. Be open to reorganize namespace if at anytime u feel it has become illogical or hard to manage.
  5. Do not create namespaces just for the sake of it.

Happy Coding!!!


If building a library or a module, it is generally better to use only one namespace, since the primary function of a namespace is to avoid name collisions and you have the control over what names get assigned to classes and interfaces.


I don't know of any rule of thumb for the number of items, but those kinds of rules tend to be over-generalized garbage anyway. Make sure there is a logical connection between items in the same namespace. If a namespace is getting too crowded (unlikely, I hope), or the things in the namespace are only loosely related at best, consider breaking it up into multiple namespaces.