I have used Handlers mapping along with if else conditional construct to handle chains which are request dependent.
Request r(TYPE1, ACTIVE);
std::vector<TYPE, STATUS> mapping;
mapping[TYPE1][PENDING] = myHandlerA();
// ... and so on
mapping[r.type()][r.status()]();
void myHandlerA(Request& r) {
if(condition4(r))
Handler4(r);
else if(condition5(r))
Handler5(r);
else if(condition6(r))
Handler6(r);
else if(condition7(r))
Handler7()
}
- How do I do it using CoR when the chain is dependent on the request ? Is my approach a good design ?
- Is this case applicable to CoR ? Can someone provide a snippet, if yes.
- How does one identify applicability of CoR vs a simple mapping based coupled with if else ?
Aucun commentaire:
Enregistrer un commentaire