This image is taken from Applying Domain-Driven Design and Patterns: With Examples in C# and .NET
This is the class diagram for the State PatternState Pattern where a
SalesOrder can have different states during its life time. Only certain transitions are allowed between the different states.
OrderState class is an
abstract class and all its methods are inherited to its subclasses. If we consider the subclass
Cancelled which is a final state that doesn't allow any transitions to any other states, we'll have to
override all its methods in this class to throw exceptions.
Now doesn't that violate Liskov's substitution principle since a sublcass shouldn't alter the behavior of the parent? Does changing the abstract class into an interface fixes this?
How can this be fixed?