6

English in not my native language, therefore it is a little more difficult to pick a good name for a namespace. One example to make you see my problem a bit better:

We have a set of classes that have to do with the way a company is organized (we can create organizational charts with it). Currently the namespace is CFW.CoreSystem.Organizational. Is this a good name?

What is linguistically the best way to name a namespace? (CFW.CoreSystem.Configuration is better than CFW.CoreSystem.Configurables).

[Moved it from StackOverflow]

1 Answer 1

9

The name chosen for a namespace should indicate the functionality made available by types in the namespace. For example, the System.Net.Sockets namespace contains types that enable developers to use sockets to communicate over networks.

The general format for a namespace name is as follows:

<Company>.(<Product>|<Technology>)[.<Feature>][.<Subnamespace>]

For example, Microsoft.WindowsMobile.DirectX.

Do use Pascal casing, and separate namespace components with periods (for example, Microsoft.Office.PowerPoint). If your brand employs nontraditional casing, you should follow the casing defined by your brand, even if it deviates from normal namespace casing.

Consider using plural namespace names where appropriate. For example, use System.Collections instead of System.Collection. Brand names and acronyms are exceptions to this rule, however. For example, use System.IO instead of System.IOs.

Do not use the same name for a namespace and a type in that namespace. For example, do not use Debug for a namespace name and also provide a class named Debug in the same namespace. Several compilers require such types to be fully qualified.

There are lots of Do or Do'not detail on MSDN regarding Naming of namespace, Assemblies etc. Check this out for Namespaces

CFW.CoreSystem.Configuration is better.

The Namespace CFW.CoreSystem.Organizational is pretty good but CFW.CoreSystem.Organization is much better to write.

4
  • I know the guidelines... but as a non native English speaker I was wondering why Configuration is better than Configurable? Nov 26, 2011 at 13:50
  • 1
    It's more common to use nouns in namespaces. I see you're Dutch, so maybe it's more understandable when I say it in Dutch: het is gebruikelijk om zelfstandige naamwoorden te gebruiken in namespaces. In jouw geval zou Configurables vertalen naar 'configureerbaarheden' en Configuration naar 'configuratie'. Waarbij de tweede optie toch iets beter klinkt. Nov 26, 2011 at 14:15
  • @kees I'd say Configuration is better because the namespace contains functionality regarding the application Configuration - it could also contain relevant utilities and the like. Configurables tells me that everything within that namespace is something that is configurable. Which might not be the case. Nov 26, 2011 at 18:43
  • @KeesC.Bakker I'm late, but the reason a namespace called Configuration is better than Configurable is that nouns, rather than adjectives, should be used to name namespaces. For example Configuration is a noun. Adjectives are more appropriate for interfaces (e.g. IConfigurable, ISerializable, etc).
    – code_dredd
    Apr 30, 2018 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.