3 ms·
A key insight can be to abstract behaviors, rather than state. It is typically much more possible to cleanly abstract the behavior for a single interaction/ ro
by twhitmore 6y ago
A key insight can be to abstract behaviors, rather than state.
It is typically much more possible to cleanly abstract the behavior for a single interaction/ role, than for the entirety of an entity's state. If you have multiple interactions you might want to use more than one interface.
Once you have clean behavioral APIs for your interactions, you may also be able to use composition, wrapping and delegation to implement/ enhance behavior. This is the 'Strategy pattern'.
The one thing you lose here is object identity -- you can no longer assume a delegate is the entity itself. This is no big loss given the clarity & flexibility that are gained.