116

I distinctly remember that, at one time, the guideline pushed by Microsoft was to add the "Base" suffix to an abstract class to obviate the fact that it was abstract. Hence, we have classes like System.Web.Hosting.VirtualFileBase, System.Configuration.ConfigurationValidatorBase, System.Windows.Forms.ButtonBase, and, of course, System.Collections.CollectionBase.

But I've noticed that, of late, a lot of abstract classes in the Framework don't seem to be following this convention. For example, the following classes are all abstract but don't follow this convention:

  • System.DirectoryServices.ActiveDirectory.DirectoryServer

  • System.Configuration.ConfigurationElement

  • System.Drawing.Brush

  • System.Windows.Forms.CommonDialog

And that's just what I could drum up in a few seconds. So I went looking up what the official documentation had to say, to make sure I wasn't crazy. I found the Names of Classes, Structs, and Interfaces on MSDN at Design Guidelines for Developing Class Libraries. Oddly, I can find no mention of the guideline to add "Base" to the end of an abstract class's name. And the guidelines are no longer available for version 1.1 of the Framework.

So, am I losing it? Did this guideline ever exist? Has it just been abandoned without a word? Have I been creating long class names all by myself for the last two years for nothing?

Someone throw me a bone here.

Update I'm not crazy. The guideline existed. Krzysztof Cwalina gripes about it in 2005.

2
  • If you read that piece, Krzysztof merely complains about receiving "a set of recommendations" -- not necessarily that those recommendations were Microsoft-official. I recall reading the MS guidelines and seeing them recommend against this.
    – John Rudy
    Commented Jan 9, 2009 at 20:10
  • 1
    I did read it, although it's the first time I recall ever having seen that particular article. It's a relief, actually. I've never actually liked the recommendation. It'll save me a lot of growling from here on out. :)
    – Mike Hofer
    Commented Jan 9, 2009 at 20:24

6 Answers 6

74

In Framework Design Guidelines p 174 states:

Avoid naming base classes with a "Base" suffix if the class is intended for use in public APIs.

Also : http://blogs.msdn.com/kcwalina/archive/2005/12/16/BaseSuffix.aspx

22

Also, if the abstract class has a few static members that will be used, the 'Base' can get ugly.

15

I don't remember such a guideline. I believe you should use the naming that makes sense. Sometimes the abstract class is only designed to provide common functionality to some classes (as a tool), which I think should have the suffix. However, in some cases, you want to use it as the base of a polymorphism hierarchy which it's not complete itself. In those cases I suggest naming like a normal class.

As you see, you won't probably declare a method that accepts a ButtonBase as parameter. It's designed to provide minimal functionality for subclasses. However, you might treat a ConfigurationElement as an entity that has different forms but it is not complete on itself (and hence it's abstract)

13

Sometimes Base is still necessary, especially when you provide both a concrete class and an abstract class for someone to extend to create a concrete implementation.
e.g. Controller and ControllerBase (actually Controller is also abstract, but provides signifigantly more functionality than ControllerBase)

Base suffix is ugly when programming against an interface, so I think the Microsoft guideline not to use it applies when the abstract class is predominantly used like an interface. Probably what they mean by Public API.

The point is that there are cases where there is no better alternative to using the Base suffix.

1
  • 4
    I agree. I'm working in a feeds system that parses content from different sources. We use in the public API an interface named IFeedParser, and internally we use a base abstract class containing common functionality named BaseFeedParser Commented Nov 14, 2012 at 11:23
4

Microsoft states, at:

https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces

✓ CONSIDER ending the name of derived classes with the name of the base class. This is very readable and explains the relationship clearly. Some examples of this in code are: ArgumentOutOfRangeException, which is a kind of Exception, and SerializableAttribute, which is a kind of Attribute. However, it is important to use reasonable judgment in applying this guideline; for example, the Button class is a kind of Control event, although Control doesn’t appear in its name.

Generally speaking, this implicitly rules out using "Base" in the name.

3

I understand the inclination to avoid a Base-Suffix, but I also understand the need for some Suffix. Now, a Comment of this article suggests using "Type" as a Suffix as second choice to not using any. I believe this to be confusing, but the Idea that "such a non-committal word would tend to indicate that it’s a non-committed class" stuck with me.

As an Alternative: I'd prefer using "Kind" as a suffix to state the object as “of or belonging to a specified race or family” (Wiktionary: -kind).

Example: DataProvider and ReflectiveDataProvider are both DataProviderKind

Inspired by Biology where e.g. "canis lupus" belongs to the family "Canoidea", which very roughly translates to "dog-ish".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.