#531 – Best Practices for Naming Namespaces

In C#, a namespace declaration specifies the name of the namespace and you can use any valid C# identifier as the name.  However, it’s generally considered good practice to follow the suggestions listed below when naming namespaces.

  • Use Pascal Casing for each portion of the namespace, capitalizing the first letter of each word.  E.g. Acme.AfricanAnimalLibrary
  • Do not use underscores
  • Use sub-namespaces to organize/group related namespaces
  • The highest two levels of namespaces should follow the pattern CompanyName.ProductName or CompanyName.TechnologyName.  E.g. Acme.SearchEngine.Logging or Acme.Rendering.3DTools


Incorporating your company or organization name into the namespace hierarchy helps ensure that your types are globally unique.

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: