I have a class with some default/shared functionality. I use abstract class
for it:
public interface ITypeNameMapper
{
string Map(TypeDefinition typeDefinition);
}
public abstract class TypeNameMapper : ITypeNameMapper
{
public virtual string Map(TypeDefinition typeDefinition)
{
if (typeDefinition is ClassDefinition classDefinition)
{
return Map(classDefinition);
}
...
throw new ArgumentOutOfRangeException(nameof(typeDefinition));
}
protected abstract string Map(ClassDefinition classDefinition);
}
As you can see, I also have the interface ITypeNameMapper
. Does it make sense to define this interface if I already have an abstract class TypeNameMapper
or abstract class
is just enough?
TypeDefinition
in this minimal example is abstract too.