Class Names in C# (English vs Intellisense)

I'm using Visual Studio 2013 to write C# code.

How should I name my classes? In a "English-friendly" way, or in a way thats more IntelliSense- friendly.

For instance, I have a interface called IColorComparer. And a few classes that implement that interface:

QuadraticColorComparer vs ColorComparerQuadratic
DefaultColorComparer vs ColorComparerDefault
TrauerColorComparer vs ColorComparerTrauer

Question: Is there a official naming convention for Classes in C# / VS? Does it take tools like IntelliSense into account?

Jon Skeet
people
quotationmark

It usually makes sense to put the differentiator at the start. For example:

  • TextReader / StreamReader / StringReader
  • Stream / FileStream / MemoryStream / NetworkStream

It's like having an adjective to provide more detail: "the red book, the blue book".

One alternative option is to avoid exposing the classes themselves, and instead have:

public static class ColorComparers
{
    public static IColorComparer Quadratic { get { ... } }
    public static IColorComparer Default { get { ... } }
    public static IColorComparer Trauer { get { ... } }
}

Then you'd just use it as:

IColorComparer comparer = ColorComparers.Quadratic;

Does anything else really need the implementation details? The implementations could even be private nested classes within ColorComparers.

people

See more on this question at Stackoverflow