Two different patterns:

  1. Acting on a single object by multiple services that can modify it as they wish. So basically we would have some kind of a "chain" that modifies a single object by going through multiple handlers, that can be added to it. The modified object is an output of such chain. Every element of the chain has to support modifying our input object by implementing the same interface.

  2. We can register multiple services to process our object, but only the first one/the one with the highest priority "wins". The output can be anything, all services implement the common interface, but not all have to support processing of our input object. The one with the highest priority that actually can handle our object wins.

Do they have specific names? What would be the closest patterns to them?

  • Sounds like you're looking for the Actor Model. Jul 6, 2020 at 14:52

1 Answer 1


Number 2 sounds like a variant of the Chain of Responsibility Pattern (https://sourcemaking.com/design_patterns/chain_of_responsibility) in which the processors are sorted by priority and once one handles the input, all execution ceases.

There probably isn't a great Gang-of-four type pattern that differentiates the first case from the second, but I tend to think of the first as a filter pattern (after the | operator in shell programming; see: http://www.linfo.org/filters.html). I've gotten some really good mileage over the years by building filter pipelines in object-oriented languages (Java/C#) for certain gnarly types of problem.

  • 1
    The first one sounds like Intercepting Filter pattern.
    – iluwatar
    Jul 7, 2020 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.