Questions tagged [chain-of-responsibility]

Design pattern consisting of a source of command objects and a series of processing objects. One of the Gang of Four's behavioral design patterns.

Design pattern consisting of a source of command objects and a series of processing objects. Each processing object contains logic that defines the types of command objects that it can handle; the rest are passed to the next processing object in the chain. A mechanism also exists for adding new processing objects to the end of this chain.

This is one of the Gang of Four's behavioral , first published in Gamma et al.'s book "Design Patterns: Elements of Reusable Object-Oriented Software".

More information is available on Wikipedia.

160 questions
2
votes
1 answer

chain of responsibility design pattern - regd

I've seen some questions on this pattern but I am trying to understand more about this design pattern in depth. Any resources in this regard, experts commentary on what scenarios they tend to use this pattern and what scenarios to avoid and some…
A_Var
  • 1,056
  • 1
  • 13
  • 23
2
votes
1 answer

Chain Of Responsibility- Servicer1 not calling Servicer2

I am trying to demonstrate use of chain of responsibility pattern by searching characters/ string inside Servicer class strings. The code runs but Servicer1 ServiceReq is not calling Servicer2 ServiceReq. If I run this with "g", I get"Checked…
kunal279
  • 31
  • 1
  • 4
2
votes
1 answer

Swift compiler is unable to resolve recursive use of generics

I am trying to implement the chain of responsibility pattern in Swift. public class Chain { private var command: (T?, (U?) -> Void) -> Void private var runCommand: (() -> Void)? private var nextCommand: ((U?) -> Void)? private…
Adrien Cadet
  • 1,311
  • 2
  • 15
  • 21
2
votes
3 answers

Implement Chain of Responsibility using Generics

So I want to implements the Chain of Responsibility but use generics, with an upper bound. public abstract class Handler { private Handler successor; public Handler(Handler
dalvarezmartinez1
  • 1,385
  • 1
  • 17
  • 26
2
votes
1 answer

Chain of Responsibility Performance

I have code that I want to modify applying the Chain of Responsibility (CoR) pattern, but I have a doubt about performance if I have many successors. First, this is the code without CoR: public class OperationService { public Response…
AiApaec
  • 660
  • 1
  • 6
  • 12
2
votes
2 answers

Chain of Responsibility with Thread Pools

I have a chain of responsibility that consists of 3 stages. My Implementations for the stages look like this. public class InitialStage implements RecordHandler { private RecordHandler next; @Override public void setNext(RecordHandler…
2
votes
2 answers

Command pattern along with Chain of responsibility

In my application, I need to load data from a DB in a certain sequence of steps, example load all customers, then load all orders and load products etc. However, in one or two cases, the order is different and also need to load additional…
user320587
  • 1,347
  • 7
  • 29
  • 57
2
votes
1 answer

Can the chain of responsibility have multiple nodes modify the request?

If I have multiple nodes that will need to modify a request, is it a good idea to still utilize the 'Chain of Responsibility' Design Pattern? Or should this pattern only be utilized when only one (unknown) node will exclusively handle the…
veilig
  • 5,085
  • 10
  • 48
  • 86
2
votes
3 answers

Design Pattern to allow code to be injected at certain points

I am trying to allow developers to extend my code at certain points of execution. My specific example is a database transaction wrapper. The wrapper takes care of many details that we wanted to abstract away from the developer and is used on…
Mike Schall
  • 5,829
  • 4
  • 41
  • 47
2
votes
3 answers

In what cases the Chain of Command design pattern is applicable?

Please somebody clears me up the mess in my head with these patterns: Chain of Command Chain of Responsibility I've seen sites in which both are the same (examples of Chain of Command which are the same as Chain of Responsibility), and other…
2
votes
1 answer

Too much if-else in an Oracle procedure, Good or bad on performance?

In a procedure, I need to decide about the value of a column using many if-else conditions. The script starts with a FOR rec IN (SELECT....) LOOP Begin and decides on many different values the rec sub-records can obtain in each iteration. for…
Farshid
  • 5,134
  • 9
  • 59
  • 87
1
vote
2 answers

Is HashMap in a chain of responsibility an abuse of the pattern?

I've seen an example implementation of the CoR pattern using a HashMap as the object that is passed down the chain, possibly with new content being added to it by handlers; an outline of the code below: class HandlerImpl implements Handler { …
MaDa
  • 10,511
  • 9
  • 46
  • 84
1
vote
0 answers

Cannot get the right this with using apply(), and got TypeScript error: An outer value of 'this' is shadowed by this container

I have a class Chain with a method syncPassRequest in which I used the apply() method to set a class instance as another function's (this.fn) this. When I tried console.log(this) in a function which will be passed to the class instance, I found…
1
vote
1 answer

Pipeline design chain of responsibility pattern

I'm designing a pipeline, in its simplest form: a customer applies for a loan, the request goes to the credit score service, after the credit score is calculated, it goes to the credit service with the credit score and the approval or rejection of…
1
vote
1 answer

Chain of transformations based on generic types

I'm thinking about a chain, that will allow me to perform a set of transformations with data type changing from transformation to transformation. So far I've got something like this: public abstract class TransformationStep { public…
bartek618
  • 11
  • 1