4

Silly question but it's been a long time since I properly coded in C#, and I've forgotten my naming standards and run into a mental block, so to speak!

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

I was thinking of naming the class as "Common" but was wondering if that was a little too generic?

4
  • That's quite generic. What's the purpose of the class? Commented May 8, 2011 at 4:47
  • The class is doing DB lookups, holding string consts and also executing packages/process Commented May 8, 2011 at 4:58
  • 1
    That seems too diverse for a single class. Commented May 8, 2011 at 5:01
  • Very true, its only a unit test class and wont be run in production Commented May 8, 2011 at 5:05

2 Answers 2

7

The class name should generally indicate the function of the class. "Common" is generally better as part of the name for a library (e.g. "Common.Logging" or "Ninject.Web.Common") to indicate that the files within that library are common to a particular purpose, and likely to be used by a number of other libraries.

You'll need to share more information about the purpose of the class you're creating if you want better ideas for what to call the class. But in general, it's good to think of the "consumer's" experience. For example, which makes more sense?

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

... or:

var log = new LogService(); log.LogInfo("something happened"); 
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect mate, I had a feeling that was the case! I will change!
1

Usually, I use "Shared" or Utils for these kind of projects.

And generally, I do not add other namespaces to it, e.g. I prefer Utils to MyProject.Utils, Except when I modify Utils to serve explicitly for that project, then I rename it to MyProject.Shared or MyProject.Utils.
Hope this helps.

2 Comments

using utils, shared, manager, in class names. almost certainly breaks SOLID at the first hurdle ('S'). Don't be lazy, just create one function per class if needs be and name it properly!
@jenson-button-event Agreed. I was young and foolish back then. manager though, can be used in combination with other words (e.g. similar to the usage of word serice) IMHO.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.