vendredi 29 mai 2020

CoR vs simple if else and matrix based functional calls where the chain is request dependent

Scenario

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()
}
  1. How do I do it using CoR when the chain is dependent on the request ? Is my approach a good design ?
  2. Is this case applicable to CoR ? Can someone provide a snippet, if yes.
  3. How does one identify applicability of CoR vs a simple mapping based coupled with if else ?

Aucun commentaire:

Enregistrer un commentaire