I have been wondering about this for a long time.
I have to perform this process -
process(){
bool allow=checkForPermission();
if(allow) {
processRequest();
}
sendResponse();
}
Now I have made an abstract Class X with three abstract methods:
abstract class X {
public abstract sendResponse();
public abstract checkPermission();
public abstract sendResponse();
public abstract example(); // some example which is called from sendResponse() from where it is implemented.
public void process() {
bool allow=checkForPermission();
if(allow) {
processRequest();
}
sendResponse();
}
}
Class A extends X; this is where I am uncertain. When A is implementing all the abstract methods, and in sendResponse() method it is making a call to IfError() Function, is it a good design?
My friend suggests this: Its like compiler will first call X.process() then to A implemented methods, and again A to X (where sendResponse() will call example() method), which my friend said is not a good design:
X obj = new A();
obj.process();
Will it be a good design?
Aucun commentaire:
Enregistrer un commentaire