Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prefixing abstract classes with "A" like interfaces are prefixed with "I"?

It seems to me that it'd be useful to be able to tell at a glance that a class is abstract and not meant to be directly instantiated just like it's useful to be able to easily identify an interface.

My question is, why didn't "AFourLeggedAnimal : IAnimal" catch on? Is it simply because of the possible confusion (which I just noticed while writing that) for example confusing it as "A four legged animal" instead of "abstract class FourLeggedAnimal"? Or is it something more?

Coming from Java in school to C# at work, I found the "I" prefix naming convention extremely useful when glancing through a list of classes and it seems to me that it'd be convenient to be able to distinguish between concrete and non-concrete classes at a glance without needing to look at the code.

like image 298
Davy8 Avatar asked Nov 27 '22 04:11

Davy8


1 Answers

Use the suffix "Base" as Joel mentions. Once you have a lot in your project, it's pretty easy to tell apart:

public abstract AnimalBase
{
  public AnimalType AnimalType { get; set; }
}

public abstract HorseBase : AnimalBase
{
  public HoovesManufacturer HoovesManufacturer { get; set; }
}

public class Pony : HorseBase
{
  public Pony()
  {
  }
}
like image 190
eduncan911 Avatar answered May 30 '23 05:05

eduncan911