I have some classes (actions) which need to be run in a sequence. (Action A, B , C .... Z) There are two checks in place to figure out if the sequence can be called off.
The first check is a simple check performed before Action C. Action C, then does a heavy task (which is why it is a separate class) of getting some data (object B) which is then used in Action D to do an extended check if the sequence can be called off.
Is there a good design pattern (in Java) to go forward with this? Because the basic function of both actions B and D is to perform a check if the sequence can be called off and I have two classes for it. Is this good practice?
public class B implements Sequence{
public void importantTask() {
*-- DO SOMETHING --*
}
public boolean checkIfSequenceCanBeCalledOff(Object a) {
}
}
public class C implements Sequence{
public void importantTask() {
//Heavy task
getObjectB();
}
}
public class D implements Sequence{
public void importantTask() {
*-- DO SOMETHING --*
}
public boolean checkIfSequenceCanBeCalledOff(Object a, Object b) {
}
}
Aucun commentaire:
Enregistrer un commentaire