I have some client classes A
, B
and C
that need to use an operation op()
that depends on the type of the caller and it's defined by another class D
.
There are a few solutions:
D
exposes a different method for each client but the responsibility of choosing the right implementation is left to the client:
- overloading the method name in
D
and passing the client self-reference to drive the binding:
- introducing a strategy pattern.
- ...
Is there some good practice why I should avoid the second solution?