1

How does a CoR pattern compare to implementing the items in the chain as a list and having a single orchestrator class try the items in this list sequentially?

Which is a better approach?

Example:

Class A implements NodeInAChain{

NodeInAChain nextNode;

public Result doWork(Request request){
// Some logic
if(logicSuccessful) {
 return;
else
 nextNode.doWork(request);
}
}

Vs

Class ChainOrchestrator {

List<NodeInAChain> nodeList;

public Result doWork(Request request){
foreach(node : nodeList) {
 if(node.doWork(request) == 'success'){
   break;
 } 
}
return result;
}

`

Roger
  • 123
  • 2
  • 7
  • Possible duplicate of [What are the advantages of chain-of-responsibility vs. lists of classes?](https://stackoverflow.com/questions/1055383/what-are-the-advantages-of-chain-of-responsibility-vs-lists-of-classes) – jaco0646 Aug 17 '19 at 12:37
  • Possible duplicate of [Is Chain of Responsibility pattern just an overkill ? A List of Handlers can accomplish the same](https://stackoverflow.com/questions/55979891/is-chain-of-responsibility-pattern-just-an-overkill-a-list-of-handlers-can-acc) – Matt Timmermans Aug 19 '19 at 12:33

0 Answers0