Are there some principles of organizing classes into namespaces?
For example is it OK if classes from namespace N depends on classes from N.X? And if classes from N.X depends on classes from N?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In general, that should be fine for your example, if your packages were ‘N.UI’ and ‘N.Util’. I’ve seen namespaces used in two general fashions:
1) All tiers of a system have a namespace (i.e. database, web, biz, etc.)
2) Each component has a namespace (i.e. Customer, Invoice) and tiered namespaced underneath
Either way, the sub namespaces would be inter-related packages within a larger namespace, so it would be perfectly fine for you UI code to depend on your domain objects.
However, while it would be fine for N.X classes to depend on classes from N, I don’t think it would make much sense for classes from N to depend on classes from N.X – it sounds like you could use some reorganization in that case.