chain-of-responsibility

Application design for processing data prior to database

I have a large collection of data in an excel file (and csv files). The data needs to be placed into a database (mysql). However, before it goes into the database it needs to be processed..for example if columns 1 is less than column 3 add 4 to column 2. There are quite a few rules that must be followed before the information is persiste...

What are the known "gotchas" with regards to the Chain of Responsibilty pattern?

I have been finding myself using the Chain of Responsibility pattern often (3 times is often for me) in my current project and I'm wondering if I have become a little over-enthusiastic about the solution. Specifically, I have been using the Apache Commons chain project. So, far I have been quite impressed by how it has simplified a numbe...

Replace giant switch statement with what?

I have a code that parses some template files and when it finds a placeholder, it replaces it with a value. Something like: <html> <head> <title>%title%</title> </head> <body bgcolor="%color%"> ...etc. In code, the parser finds those, calls this function: string getContent(const string& name) { if (name == "title") re...

How do I declare a chain of responsibility using decorators in Ninject?

I'd like to declare a chain of responsibility using decorators in Ninject. Has anyone done that before? Thanks. ...

Why would I ever use a Chain of Responsibility over a Decorator?

I'm just reading up on the Chain of Responsibility pattern and I'm having trouble imagining a scenario when I would prefer its use over that of decorator. What do you think? Does CoR have a niche use? ...

What are the advantages of chain-of-responsibility vs. lists of classes?

Recently, I was discussing with another programmer the best way to refactor a huge(1000 lines) method full of "if" statements. The code is written in Java, but I guess this issue could happen in other languages such as C# as well. To solve this problem, he suggested using a chain-of-responsibility pattern. He proposed having a base "Ha...

How would you test something that filters complex objects

I have a persistent object with 7 pertinent fields. The fields can hold the number of values listed here: Field # of Possible Values 1 5 2 20 3 2 4 2 5 19 6 2 7 8 Which is a potential for 121600 unique objects. The code under test is a number of filters that grab a certain number...

Is this possible in PHP?

Consider the following PHP snippet: <?php class Is { function __get($key) { $class = __CLASS__ . '_' . $key; if (class_exists($class) === true) { return $this->$key = new $class(); } return false; } function Domain($string) { if (preg_match('~^[0-9a-z\-]{1,63}\.[a-z]{2,6}$~i', ...

C# -Pipeline Style event model

In ASP.NET Web Apps , events are fired in particluar order : for simplicity Load => validation =>postback =>rendering Suppose I want to develop such pipeline -styled event Example : Event 1 [ "Audiance are gathering" ,Guys{ Event 2 and Event 3 Please wait until i signal }] after Event 1 finished it task Event 2 [ { Event 2, ...

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 several projects. Each project however has certain things they would like to do automatically ...

wpf events and chain of responsibility pattern

do routed events from wpf have something in common with the chain of responsibility pattern ? i googled for this and i don't see anyone talking about this :S, although i though that the routed events are an implementation of that pattern ...

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 because I would realize that a certain pattern is the very one used in some WPF functio...

How to use a touch in both the view and the viewcontroller?

I have a simple UIView with touchesBegan... implemented, and I process the touches in the view, but I want the viewcontroller to know when a touch occurs. No specific information about the touch is necessary for the viewcontroller. Is there an easy way to do this, and if not, what's the hard way? Thanks in advance for any help. John ...

Would this be a pipeline, a chain of responsibility, or something else?

I'm building a multiprocess architecture that seems to be a strange meld of a pipeline and a chain of responsibility. Essentially, I have a chain of handlers linked up by queues. Each handler will receive an object that represents the input data, forward it to the next handler so that it can start working on it, and then determine if i...

Composite + Chain of Responsibility example

Hello! Can anyone give a practical example of using the design patterns Composite and Chain of Responsibility together? Thanks ...

C# Chain-of-responsibility with delegates

For my understanding purpose i have implemented Chain-Of-Responsibility pattern. //Abstract Base Type public abstract class CustomerServiceDesk { protected CustomerServiceDesk _nextHandler; public abstract void ServeCustomers(Customer _customer); public void SetupHadler(CustomerServiceDesk _nextHandler) { this._nextHandl...

Chain of Responsibility Pattern: is it a good practice to have interdependent handlers?

I have this scenario: I have a chain of query handlers, the first is to query the cache, if the cache can't answer it or the answer is stale, then hit a database, if it can't find the answer or the answer is stale again, then query a remote web service. But I am not sure if this is the right way to use this pattern, since the work flow...

What would you like to correct and/or improve in this java implementation of Chain Of Responsibility ?

package design.pattern.behavioral; import design.pattern.behavioral.ChainOfResponsibility.*; public class ChainOfResponsibility { public static class Chain { private Request[] requests = null; private Handler[] handlers = null; public Chain(Handler[] handlers, Request[] requests){ this.handlers =...

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 the class isn't loaded or something so I explicity do a send to get the method I get a bu...

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 help demonstrate my question a little better than status. Here is a sample Account object: ...