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
0
votes
0 answers

Handle class behaving like union

I have a case that I want return an object that is populated by multiple concrete classes. Specific example: public interface MovieHandler { UserPreferences process(Context context, Customer customer, History customerHistory); } Concrete…
Jim
  • 3,845
  • 3
  • 22
  • 47
0
votes
0 answers

Refactoring Guru chain of responsability in rust with reference to objects

I'm trying to implement the chain of responsibility from refactoring guru https://refactoring.guru/design-patterns/chain-of-responsibility/rust/example But instead I need to pass the object by reference as they need to be called later on let…
will.mendil
  • 752
  • 2
  • 6
  • 21
0
votes
1 answer

Windsor Castle Chain Of Responsibility ending and sorting

I am writing a list of filters as a chain and each filter has the next link in its constructor so if a certain chain link can't handle the request it passes it along until it can. public class SomeFilter : ISomeFilter { …
0
votes
2 answers

code refactoring for data aggregation service in java

I have the following situation in my application: I have a service class with 700+ lines The class is responsible for data aggregation from different sources. There is no real signature in the inputs, as I mentioned in the code example. The service…
mzaje18
  • 1
  • 1
  • 3
0
votes
0 answers

Who is responsible for checking state?

I'm currently building a consent management system consisting of 3 layers: Handlers/Controllers (Rest) Services (Logic) Repositories (Microsoft SQL) This is the scenario: I'm fetching the identifier (Id) from a model inside of the database. But…
0
votes
1 answer

Converting Kotlin functional programming code to object oriented classes

I have the code for the design pattern Chain Of Resposibility in functional programming. I'm trying to convert it to regular OOP classes. Following is the working code for the design pattern: Functional Programming Code enum class LogLevel { …
0
votes
1 answer

Django 'Handler' is not defined

I'm currently working on a Django REST project, and trying to implement the Chain of responsibility pattern on it. Since I downgraded my Python version from 3.9.2 to 3.6.5, I've encountered another problem, which is the following: NameError: name…
user15401084
0
votes
1 answer

Implementing chain of responisiblity in C with FILE* and array of structs

My goal is to create a program that writes from the CMD straight to a text file. If the input string is one of the following strings: -exit -count -remove It will do the tasks of exiting the program / counting lines in the file / removing the…
NoobCoder
  • 513
  • 3
  • 18
0
votes
1 answer

Design Pattern for conditional behaviour depending on a param

I need suggestions about the right choice of a design pattern. I have three kind of tasks (but could be more in future) TaskA, TaskB, TaskC. The controller receive some params and have to perform TaskA and TaskB if the param X has value major to 10,…
Zauker
  • 2,344
  • 3
  • 27
  • 36
0
votes
1 answer

Synchronization with Chain Of Responsibilities Design Pattern

I have a big method in java, I want to break it into small small responsibilities, So as to use Chain of Responsibilities design pattern to make my code maintainable. Since my method is synchronized, can I still use Chain of Responsibilities with…
0
votes
1 answer

Decorator vs Chain of Responsibility DP

Is there an example of a system which uses Decorator design pattern that isn't suitable for Chain of Responsibility design pattern? Note: I'm not searching for an explanation, I need an example to my specific problem.
0
votes
2 answers

Would this still be considered a Chain-of-Responsiblity pattern?

I have been using a design pattern for quite some time and have been calling/referring to it as a "Chain-of-Responsibility pattern" but now I realise there are differences, and it may not be appropriate to do so. So my question is 1, "is the…
Sled
  • 18,541
  • 27
  • 119
  • 168
0
votes
2 answers

What pattern to use?: Chain of handlers where next handler needs to know the result of previos handler

I am working on a solution where I have implemented chain of responsibility pattern. All handlers in chain work independently and in some cases based on the input the chain is broken by a handler since there is no need to continue with the next…
0
votes
2 answers

How to write Java's default method of a functional interface in Kotlin idiomatically?

I'm trying to convert the Java code of a design pattern called Chain of Responsibility in Kotlin idiomatically. But I'm not getting any clue on converting the default method appendNext() of Java interface in Kotlin. I tried some already existing…
0
votes
2 answers

Understanding the need for struts 2 and commons chain in simple CRUD website

I have a simple CRUD website in development process, almost done. I was asked to refactor the code but this time use struts 2 and commons chain. I read a couple of sites like this but wasn't able to know exactly what will be the key roles done by…
AabinGunz
  • 12,109
  • 54
  • 146
  • 218