I found myself dumbstruck trying to name a class with the following characteristics :
Let's say the Business interface defines two complex operations:
interface Service {
void doSomething();
void doSomethingElse();
}
A third party provided an implementation that is partially correct :
final class DefaultService implements Service {
void doSomething() {
// OK
}
void doSomethingElse() {
// KO
}
}
Since extension is not an option, I created a class that delegates to DefaultService the correct doSomething() method, and has its own implementation of doSomethingElse() :
final class IDontKnowTheName implements Service {
private DefaultService delegate;
void doSomething() {
delegate.doSomething();
}
void doSomethingElse() {
// Roll new implementation here
}
}
Is there a name for an "overriding/delegating" class ?
- Not an Adapter since the original class
DefaultServicealready implemented theServiceinterface - Not a Delegate because a method is overridden
- Not really a Decorator either because some functionality of the target class is replaced, not enhanced
Aucun commentaire:
Enregistrer un commentaire