C# Class naming convention: Is it BaseClass or ClassBase or AbstractClass

Soni Ali picture Soni Ali · May 5, 2009 · Viewed 46.2k times · Source

What is the recommended approach to naming base classes? Is it prefixing the type name with "Base" or "Abstract" or would we just suffix it with "Base"?

Consider the following:

type: ViewModel e.g. MainViewModel, ReportViewModel

base class: BaseViewModel or ViewModelBase or AbstractViewModel

Also consider:

type: Product e.g. VirtualProduct, ExpiringProduct

base class: BaseProduct or ProductBase or AbstractProduct

Which do you think is more standard?

class Entity : EntityBase
{
}

or

class Entity : BaseEntity
{
}

Answer

Joe picture Joe · May 5, 2009

There are examples in the Framework with the Base suffix, e.g. System.Configuration.Provider.ProviderBase, System.Web.SessionState.SessionStateStoreProviderBase.

But by no means all abstract base classes in the Framework follow this convention (e.g. System.Data.Common.DbParameter, System.Data.Common.DbCommand).

Personally I would avoid using the suffix unless I wanted to emphasize the fact that it's an abstract class and felt that otherwise users of the class might expect the name to indicate a concrete implementation.