Multiple namespaces in a project

Here's a funny one - last night I had a chat to a new developer. He's throwing himself into .Net and leaving Java (good on him!).

After having had a look at his code, which is generally sound, he has a LOT of projects. His response was "a project should only contain one namespace to make logical ordering of classes easier to navigate".

We discussed this and i noticed that there's two very seperate minds on this.

1) As long as functionality is dictated by the namespace it doesn't matter.

or...

2) The namespace should be directly related to the project it resides in.

For instance a business model project:

MyProject.BusinessModels.ServiceDiscovery
MyProject.BusinessModels.AuthenticationServices
MyProject.BusinessModels.ServiceTokens

Once you reference the assembly/project, the logic of keeping it seperated is not beyond me. You don't see this seperation when you code but as the solution grows it can become rather "busy" in there.

So, should you keep 1 project for 1 namespace?

I believe you should and i commend this young fella for keeping his logic and architecture simple :)

Published Wednesday, October 10, 2007 9:54 AM by Brian Madsen

Comments

# re: Multiple namespaces in a project

my philosophy - keep the namespaces in the same assembly if they are somewhat related to each other, and should be loaded at the one time. Divvy the project up into a folder structure that represents your namespace heirarchy, but keep these folders still in the same project, unless there is a strict need to seperate - i.e. a web ui, windows forms ui, and the business models would all reside in seperate projects.

Monday, October 22, 2007 12:50 PM by skware

# re: Multiple namespaces in a project

hey,

I agree. I guess as long as the methodology is accepted in your organisation it works.

i've had to change my structure a few times, based on methodologies embraced by companies i work for - sometimes it's been logical, sometimes it's been far from it.

Since intellisense doesn't distinguish between your project structure i say keep them seperated as long as logic is kept and is understandable by all.

Monday, October 22, 2007 8:14 PM by Brian Madsen