Root Namespace

  • Thread starter Thread starter Cal
  • Start date Start date
C

Cal

Should the Root Namespace be something like Microsoft.

Or maybe Microsoft.MyControl



I think the root applies only to things defined in the project. Nothing to
do with namespaces referenced in the project. Is that correct?


Thanks
 
Hi Cal,

Namespaces are for your convenience.

CalSoftwareEmpire.Controls.FancyStuff.Foo
CalSoftwareEmpire.Controls.SimpleStuff.Bar
CalSoftwareEmpire.Libraries.CalMaths
CalSoftwareEmpire.Business.CompleteApps.
CalSoftwareEmpire.Business.Apps.Maintenance
CalSoftwareEmpire.Personal.DesktopApps
CalSoftwareEmpire.Personal.Games

Something like that - or totally different. It's recommended that your root be
something particular to yourself or your organisation so that namespace clashes
are less likely when your code spreads out into the world. John Smith may has a
problem in that area.

How do you want to structure your creativity? ;-)

Regards,
Fergus
 
I wasn't very clear.

I'm wondering what should be in the Root Namespace and what should be in the
file Namespace statement.

I need a little overview of how these two things are used.


Thanks for the replies
Cal
 
Hi Cal,

The Root Namespace for a Project simply means the bit
that will be added to whatever namespaces you use in your files.

If it's blank then you must specify the whole namespace in
each file. Conversely if it's full length, you need specify no
namespace at all in the files.

But it may be that you want to subdivide your namespace
within a project - in which case your Root Namepsace would
be some common portion.

Let's use those examples.
CalSoftwareEmpire.Controls.FancyStuff
CalSoftwareEmpire.Controls.SimpleStuff
CalSoftwareEmpire.Personal.Games

Say you're working on your Controls and you keep them all
in one Project (for some reason). The Root for the Project would
be CalSoftwareEmpire.Controls. In the files containing the fancy
ones you'd have NameSpace FancyStuff. In the others you'd have
SimpleStuff. But if you had them in two separate Projects (or a
Project each, even) you'd have the full CalSoftwareEmpire.Controls.
FancyStuff as the Root.

Say you're working on one of your Games. The Root would be
CalSoftwareEmpire.Personal.Games plus the name of the game.
In your files you may have no NameSpaces at all or you might have
UI in some, Logic in others, Options in another, etc.

It just depends what's most connvenient for you. The default is
for VS to put your Project name but you can (should?) replace that
with CalSoftwareEmpire.etc.etc

Regards,
Fergus
 
Back
Top