What's a proper way to organize the packages?

K

K Viltersten

I have a solution called Solution and in it,
two projects named Project1 and Project2.

I've organized the packages in a common
namespace ComNamSpc. I.e., i have this,
in each of my source code files.

namespace ComNamSpc{ class Project1{ ... } }
namespace ComNamSpc{ class Project2{ ... } }

Now, Resharper tool claims that i should
call each project by its name as follows.

namespace Project1{ class Project1{ ... } }
namespace Project2{ class Project2{ ... } }

Is it really recommended? Can i/should i put
the namespaces in a common super namespace?
 
M

Michael B. Trausch

Now, Resharper tool claims that i should
call each project by its name as follows.

namespace Project1{ class Project1{ ... } }
namespace Project2{ class Project2{ ... } }

Is it really recommended? Can i/should i put
the namespaces in a common super namespace?

It depends on your project, and what works best for you. For the root
namespace of a project, I usually use something along the lines of:

Company.Solution.Project

.... and of course, break it down into any additional namespaces
necessary, which depends entirely on the project. It's probably best
to not have more than four levels of namespaces in your application, so
Company.Solution.Project as a root namespace gives you enough wiggle
room to divide your project up into one level of namespaces, reasonably
speaking. I suggest four levels just because it tends to be easier to
remember them that way, at least for me.

--- Mike
 
A

Arne Vajhøj

K said:
I have a solution called Solution and in it,
two projects named Project1 and Project2.

I've organized the packages in a common
namespace ComNamSpc. I.e., i have this,
in each of my source code files.

namespace ComNamSpc{ class Project1{ ... } }
namespace ComNamSpc{ class Project2{ ... } }

Now, Resharper tool claims that i should
call each project by its name as follows.

namespace Project1{ class Project1{ ... } }
namespace Project2{ class Project2{ ... } }

Is it really recommended? Can i/should i put
the namespaces in a common super namespace?

I think it is a good practice if project:namespace:dll
is 1:1:1.

That makes it a lot easier to find things.

If you want some commonality between the two then
use Sol.Proj1 and Sol.Proj2.

Arne
 
K

K Viltersten

I have a solution called Solution and in it,
I think it is a good practice if project:namespace:dll
is 1:1:1.

That makes it a lot easier to find things.

If you want some commonality between the two then
use Sol.Proj1 and Sol.Proj2.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top