user6604655 user6604655 - 1 year ago 155
C# Question

c# namespace naming conventions

Another developer at my company created a new class library using the following namespace:


Based on my experience over the years I would expect this namespace to be named as:


Which style do you normally use for your namespaces? I was thinking my style was somewhat standard. It looks cleaner to me. Can you provide any authoritative urls which recommend namespace naming conventions?

Answer Source

Interesting question. I've never seen any advice beyond "use plurals where appropriate" for C#.

Let's assume that the namespace is MyCompany.Repositories

Borrowing from a similar question posed in the Java world I would suggest that plural is valid. The components that live within the Repositories namespace will be homogeneous in the sense that they are all repositories (UserRepository, StudentRepository, LocationRepository, etc).

Conversely, a namespace like MyCompany.ReportingEngine would be valid as a singularly-named namespace, as this namespace may contain heterogeneous classes that do very different things (IE a query generator class, a report model, a field model, a filtering model). MyCompany.ReportingEngines would suggest that this namespace contains different types of classes that are reporting engines.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download