1

Possible Duplicates:
Using “Base” in a Class Name
C# Class naming convention: Is it BaseClass or ClassBase or AbstractClass
Naming Conventions for Abstract Classes

What is the better way to name base abstract classes? I still can't decide where to put 'Base' word. Should it be 'BaseMyClass' or 'MyClassBase'?

How do you name those and why?

Community
  • 1
  • 1
Vasyl Boroviak
  • 5,959
  • 5
  • 51
  • 70
  • http://stackoverflow.com/questions/429470/naming-conventions-for-abstract-classes http://stackoverflow.com/questions/510839/using-base-in-a-class-name http://stackoverflow.com/questions/826821/c-class-naming-convention-is-it-baseclass-or-classbase-or-abstractclass – Jørn Schou-Rode May 18 '10 at 08:21
  • 3
    Unless there's a concrete reason to use the words 'base' or 'class' I would avoid using them anyway. – Joe May 18 '10 at 08:23
  • Wow! I have the answer now. Thank you guys. – Vasyl Boroviak May 18 '10 at 08:28

6 Answers6

5

Imagine if you have a chain of abstract classes, would you call it MyClassBaseBaseBase then?

Avoid the use of "Base" in your name if you can. You have an abstract base class because it's somehow more generic than your concrete implementation. Name it in a more generic way then, describing what common ground it supplies for deriving classes.

If the above cant be done for some reason, I agree with the previous poster; use MyClassBase.

Jakob
  • 24,154
  • 8
  • 46
  • 57
  • 2
    Of course you would, BaseBaseBaseFactoryFactoryFactories are all the rage. –  May 19 '10 at 06:44
3

Subjective... But ok. This is my perception of things: BaseMyClass sounds like an imperative: "Base my class! Now!" :) Whereas MyClassBase is clearer... a class that is a Base

Simon
  • 9,255
  • 4
  • 37
  • 54
1

MyClassBase is the way to go.

This is subjective but calling it MyClassBase brings readabilty and symmetry in design.

this. __curious_geek
  • 42,787
  • 22
  • 113
  • 137
0

I wouldn't use the words "Base", "My" or "Class" at all but chose a name for the interface that actually describes what it is.

Andreas Brinck
  • 51,293
  • 14
  • 84
  • 114
0

A choice between between MyClassBase and BaseMyClass is like asking whether I'd prefer a kick in the nuts or a punch in the face.

I don't wish to offend, but both those names are awful. Specifically, there is no reason to include Class in the class name (unless you're modelling an eduction system). If you really need to use the class name to indicate it can't be instantiated, I would prefer to use the term Abstract, rather than Base.

As a general rule, look at how the standard libraries are named and follow that convention. If your standard libraries have names like MyClassBase and BaseMyClass, then naming is the least of your problems.

Dónal
  • 185,044
  • 174
  • 569
  • 824
0

Not sure if this is correct but when I name my base class I want that just by looking at the class name one should understand that this is meant to be inherited. like I have two versions of webpart(GoogleSearch) one for mobile and other for normal brower then I would create an abstract base named GoogleSearchWebpartBase and name the webparts as MobileGoogleSearch and GoogleSearch.

Vinay Pandey
  • 8,589
  • 9
  • 36
  • 54