Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# namespace naming conventions [closed]

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?

like image 643
user6604655 Avatar asked Aug 18 '16 19:08

user6604655


1 Answers

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.

like image 191
ravibhagw Avatar answered Oct 11 '22 11:10

ravibhagw