pencilCake
pencilCake

Reputation: 53313

Are there any guidelines for the usage of namespace in big projects?

Are there any commonly accepted guidelines for usage and organization of namespaces in big projects?

Thanks!

Upvotes: 1

Views: 442

Answers (4)

Dan Puzey
Dan Puzey

Reputation: 34218

MIcrosoft's guidance is CompanyName.TechnologyName[.Feature][.Design].

Upvotes: 4

bstack
bstack

Reputation: 2528

..

E.g. if your companys name is Sample Software Solutions and you were writing an ATM system then you might have assemblies like:

  • SSS.ATM.Domain
  • SSS.ATM.Data
  • SSS.ATM.Common(an assembly common across ATM)
  • SSS.ATM.Services
  • SSS.ATM.UI SSS.Common (an assembly common across all products)

We would then typically have some unit test assemblies:

  • SSS.ATM.Domain.UT
  • SSS.ATM.Data.UT
  • SSS.ATM.Common.UT
  • SSS.ATM.Services.UT
  • SSS.ATM.UI.UT
  • SSS.Common.UT

And there may also be one or two IT or AT assemblies (Integration / Acceptance testing) e.g.

  • SSS.ATM.Domain.IT (Integration testing the domain)
  • SSS.ATM.UI.AT (Acceptence testing through UI)

Upvotes: 0

IEnumerable
IEnumerable

Reputation: 3800

Namespaces are mainly just about avoiding Ambiguity with other classes/Objects. And in terms of organization I like to organize UI elements away from other working Function;

tip: To make sure your code is never confused with other objects use a reverse order of a domain name that may be registered for the product.

com.somecompany.app.*


    com.somecompany.Math;   
                     Math.work(a,b)

    com.somecompany.UI;
                     UI.SomeUserControl
                     UI.AnotherUserControl
                     UI.Forms;


    com.somecompany.Web;

Upvotes: 0

Sasha Reminnyi
Sasha Reminnyi

Reputation: 3532

You can try FxCop, there are some rules.

  1. Generally you can make some base prefix (company)

  2. Then add the tiers/modules of the project (DAL, UI, Common, etc)

Then I add folder names to the namespace.

So if my file with MegaUtil class is in prj Common in folder Utils/Misc it will be:

YourCompanyName.Common.Utils.Misc

Upvotes: 2

Related Questions