In template method pattern, we have a superclass which is defined abstract. And we have concrete classes that extend this class.
Assume that we add a new function to template method and override it in some of subclasses(only for using in some classes). We override this new method in other classes as empty(function has no body).
Does this operation count as code duplication?
For example, in template method we have a new function doA() (I tought to use doA() as a hook method). I want to use this function only in Class1 and between doZ() and doY().
If I add this function to template method and override this function in Class2 empty. Does this count as code duplication?
public void template(){
doX();
doY();
doZ();
}
public void template(){
doX();
doY();
doA();
doZ();
}
Aucun commentaire:
Enregistrer un commentaire