Abstract Class for Providing Flexible Behavior for Related Classes

If there is a common interface for all concrete implmentations of your abstract class, it means you are just using Inheritance to define/change certain behaviour of the class.

iCar

AbstractCar

GoCart

FastCar

You should rather prefer Composition over Inheritance.

Just turn your abstract class into a concrete implementation and inject the "behaviour" which you are trying to change from outside using Strategy Pattern.

iCar

Car

+ iMotor motor

iMotor

FastMotor

GoCartMotor

References

Nigel Thorne's answer to How to Unit Test Abstract Classes?


Backlinks