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
4
votes
3 answers

C# - Should an object be responsible for creating a history object when it changes something like status?

This is more of an architecture/best practices question than anything else, so please feel free to add your two cents. I know i stated status in the title, but this goes for any basic property of an object. I think the account example below will…
wdrone
  • 87
  • 1
  • 6
4
votes
3 answers

Composite + Chain of Responsibility example

Can anyone give a practical example of using the design patterns Composite and Chain of Responsibility together? Thanks
Fabio
  • 3,020
  • 4
  • 39
  • 62
4
votes
2 answers

Patterns used in WPF

I have been getting more involved with WPF for about a year now. A lot of things are new and sometimes it is hard to get my head wrapped around it. At the same time I am rereading the GOF Design Patterns book. A few times I would stop in the middle…
Thorsten Lorenz
  • 11,781
  • 8
  • 52
  • 62
4
votes
1 answer

Most appropriate design pattern to implement a Flow diagram/model

I have to implement a flow diagram structure in C#. I will pass in data to the first node, it will check some data item (boolean) then route the data on to one of two subsequent nodes and so on. The basic logic flow is like this: node 1 If colour…
jonho
  • 1,680
  • 2
  • 19
  • 29
4
votes
1 answer

Chain of Responsibility design pattern confusion

I understand the concept of Chain of Responsibility Pattern but maybe I'm wrongly using it. I have several types of product and I have a controller that controls the interface that is displayed for each of these types of product. The user selects…
Noor
  • 19,638
  • 38
  • 136
  • 254
4
votes
3 answers

Chain of Responsibility [GoF] disadvantages

We need to build a solution to process sales orders. The processing is done serially: each step takes care of specific tasks: check if the client has credit, check if the required item is in stock, etc. We thought of using the chain of…
Bob Rivers
  • 5,261
  • 6
  • 47
  • 59
3
votes
1 answer

FxCop (/VS2010 Code Analysis), possible to flag method result as "callers responsibility now" for IDisposable?

If I write the following code: public void Execute() { var stream = new MemoryStream(); ... } then code analysis will flag this as: Warning 1 CA2000 : Microsoft.Reliability : In method 'ServiceUser.Execute()', call…
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
3
votes
1 answer

Use annotations on Pytnon 3.6.5

I'm working on a project where I was asked to code some validations using Chain of Responsibility. I am currently using python 3.9.2 on my machine, but the project on docker is on 3.6.5 This piece of code works nice on my machine, but it breaks on…
user15401084
3
votes
0 answers

Which pattern is implemented in Django Middleware? (Chain of responsibility or Decorator)

I'm trying to figure out what pattern is used in Django Middleware. Maybe there is combination of patterns?
3
votes
1 answer

Is Chain of Responsibility pattern just an overkill ? A List of Handlers can accomplish the same

In the 'Chain of Responsibility(COR)' pattern, we create a chain of handlers. Pass the request to the first in the chain. It tries to handle it. If it cannot, it forwards the request to the next in the chain and so on. Eg. Handler1 = new…
Praveen Nvs
  • 331
  • 3
  • 14
3
votes
1 answer

Is chain of responsibility design pattern suitable for Python solution operating over hardware components

I have an OOP solution written in Python which is mostly focused on managing different kind of hardware components such as camera, servo, proximity sensors etc. What I have is a bunch of operation managers. An operation manager is basically a class…
3
votes
6 answers

Design Patterns: Many Methods Share The Same First Step

Is there a design pattern that can help me avoid repeating DoThisStepFirst() in many methods? class Program { static void Main(string[] args) { Method1(); Method2(); MethodN(); } private static void…
Jim G.
  • 15,141
  • 22
  • 103
  • 166
3
votes
1 answer

Constructor Foo::Foo receiving a reference to Foo but not copy-constructor

Suppose i have a non-copyable class Foo, and one of its constructors just happens to receive a reference to Foo. class Foo { public: Foo(Foo& parent) {...} private: void operator=(Foo); // disabled ... }; The compiler thinks that this…
anatolyg
  • 26,506
  • 9
  • 60
  • 134
3
votes
1 answer

Chain of Responsibility VS Case statements

When I read about Chain of Responsibility, it talks about separating the client from the actual processing of the data. So it says the client program calls the first member of a chain and that member determines if it can process the request and if…
3
votes
1 answer

Chain of Responsibility and alias_method problems in Ruby

I'm trying to implement the chain of responsibility pattern in Ruby and ActiveRecord for a polymorphic object. I'm having a few problems. Sometimes I get an error that a method is not defined when I try to alias_method it, I think this is because…
David
  • 537
  • 3
  • 14
1 2
3
10 11