Imagine the following situation:
As may notice the Handler
-childs and the Costumer
-childs match each other. Each Handler
has a method that takes a costumer.
Is there any good way true oo-ish to make sure that a Handler
-implementation only takes a correponding Costumer
-implementation or any childs of it?
Some examples:
Handler
will take allCostumers
HandlerA
will takeCostumerA
andCustomerAA
but notCostumerB
orCostumer
HandlerAA
will only takeCostumerAA
I came up with some ideas:
- Make the
Handler
implementation check if it's aCostumer
it knows - Create a dispatcher wich does the check
None of these seem good because always you need to hardcode the structure. If you add another subclass you need to change all logic that checks that which is quite bad.