C # Class Naming Conventions

Stupid question, but it was a long time ago, since I correctly encoded in C #, and I forgot my naming standards and, so to speak, fled to the mental block!

I have a reusable class that will be used by 50+ projects, and I want to give it my own name. The DLL namespace is correct (e.g. Client.PROJECT/PRODUCT.xxx.yyy ).

I was thinking of calling the class β€œCommon”, but I wondered if it was too general?

+4
source share
2 answers

The class name should usually point to a class function. "Common" is usually better as part of the name of the library (for example, "Common.Logging" or "Ninject.Web.Common") to indicate that the files in this library are shared for a specific purpose and are likely to be used by a number of other libraries .

You will need to provide additional information about the purpose of the class you are creating, if you need better ideas for calling the class. But overall it's good to think about the "consumer" experience. For example, what makes sense?

 var common = new Common(); common.LogInfo("something happened"); 

... or:

 var log = new LogService(); log.LogInfo("something happened"); 
+7
source

Usually for these projects I use "Shared" or Utils .

And in general, I do not add other namespaces to it, for example. I prefer from Utils to MyProject.Utils , except when I change Utils for explicit use for this project, I will rename it MyProject.Shared or MyProject.Utils .
Hope this helps.

+1
source

All Articles