Also posted here, but with no real academic answer: why namespace types should not depend on nested namespaces types?
If I understand it correctly, the point is that a type Product.Business.Modules.Module
can depend on Product.Business.Product
, but not the other way around, because Product
is the foundation for Module
. However, looking at my project structure, I violate this guideline:
namespace Product.Business
{
using Modules;
class Product
{
public IEnumerable<Module> Modules { get; }
// Module is abstract, with many different kinds defined in Modules.
}
}
However, I would like to extend the question.
- Where can I find supporting information to back this guideline?
- Why is this bad practice?
- Is it valid to have types depend on types from other namespaces with the same containing namespace? (e.g.
Product.Business.Security
depending on types inProduct.Business.Modules
?
In a sense violating this guideline creates a sort of circular namespace dependency, but I'd like to understand more of the why of this guideline rather than just a blanket statement. The only other information I was able to find was from the linked Msdn article. This can actually change the architecture and layout of a class library significantly.