lundi 18 novembre 2019

State pattern is always a good solution than If/else in C++? [on hold]

If there are some state transaction situation like below

if(conditionXXX){
 state = B;
}
else if(B && conditionYYY) {
 state = C;
}
else if(C && conditionZZZ) {
 state = D;
}
else {
 state = A;
}

Do I have to choose state pattern to resolve this situation than if/else? If yes, why? If no, why?

Aucun commentaire:

Enregistrer un commentaire