59

In C#, the interface naming convention is I<myInterfaceName> (ex: IList).

Are there any naming conventions for abstract classes?

If there aren't, what are the main recommendations?

JDB
  • 25,172
  • 5
  • 72
  • 123
binard
  • 1,726
  • 1
  • 17
  • 27

2 Answers2

36

Normally, there is no suffix/prefix used when naming abstract classes, unlike interfaces, which have the prefix "I". Just give your class a name that describes what it is for, in a short precise way.

Ganesh Jadhav
  • 2,830
  • 1
  • 20
  • 32
bpoiss
  • 13,673
  • 3
  • 35
  • 49
  • 6
    I've always seen Interfaces with an "I" **prefix** such as `IEnumerable` or `ITaxable`. – JYelton Jan 29 '14 at 23:14
  • 10
    @JYelton I think that's just a grammar mistake and he means 'there is no suffix for abstract classes, unlike interfaces which have an I-prefix convention' – Pharap Jun 03 '15 at 01:33
18

Are there a naming convention for abstract class ?

No, there are no conventions here. There are some common ways of denoting an abstract base class. The most common I've seen is to use the suffix Base. Personally, I do not like this convention, and the Framework guidelines recommend against it.

And if there aren't what is the mains recommandations ?

A good, general name that describes what the class is modeling, just like any other class name. So Shape and then Polygon and then RegularPolygon so on.

jason
  • 236,483
  • 35
  • 423
  • 525
  • 19
    Where do the framework guidelines recommend against it? You linked to the blog of one of the framework architects, not to the framework guidelines: http://msdn.microsoft.com/en-us/library/ms229042(v=vs.110).aspx (which do not appear to state anything either way). – Pharap Dec 27 '14 at 14:48
  • 10
    Downvoted because I agree with @Pharap. – Den Jun 02 '15 at 13:57
  • Presumably he linked to the blog post because the recommendation in the Framework Design Guidelines is in the book, pg. 174, according to https://stackoverflow.com/a/429494/. – Johann Nov 01 '18 at 16:37
  • 2
    That convention specifically states "Base" should not be used if it's a public API. So it is fine to name abstract classes using "Base", if its intended use is internal to the library itself. – HamsterWithPitchfork Aug 01 '20 at 08:36