I’m not even sure there is an answer\ sutiable design to this question but its worth to ask…
I have an abstract class (servlet) that get data from some clients with (among others) processResults method (abstract), and onResultsReceived (not abstract)
public abstract class dataServlet implements HttpServlets {
protected onDataReceived(){//blah blah}
public abstract void processData();
}
I onDataReceived method i’m doing some common things that is neccessary for all the implementations of processData method. If tomorrow someone will add new implementation of dataServlet, i want to be sure he will invoke onDataReceived in his processData implementation.
Is there any way, known design to do so?
It sounds like you should consider the template method pattern, as it enforces a specific order of execution, without requiring the author of the derived class to call stuff.
The pattern is: