7

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

MyCompany.Repositories.Users

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

MyCompany.Repository.User

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?

user6604655
  • 993
  • 2
  • 10
  • 20

1 Answers1

10

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.

Community
  • 1
  • 1
ravibhagw
  • 1,740
  • 17
  • 28