Recently I heard about the decider pattern1 and want to understand it and see what it can bring.

A couple of days later I’ve started by reading about the decider pattern on the website of the originator of the pattern Jérémie Chassaing2 .

I am also aware of a talk on DDD Europe on Aggregates Composition: A new view on aggregates. by Jérémie.

First impressions of the pattern

It seems to very much resemble a reducer3, something that based on a an action and a given state reduces the action to a new state. It reminds me a little bit of my experiences with Elm. Which also uses union types, and supports them just as F# natively. Not weird because both are functional languages and F# is what Jérémie uses in his talks and write up.

From what I understand reducers and Elm fall under Reactive Programming. The declarative nature of reactive programming is something what I see reflected in the decider pattern.

I can understand why this would wrap your business logic in such a way that you can write behavioral tests that allow you to refactor within. And create a testing harness that is less coupled to the implementation. It creates a very functional frontdoor4 and should provide you with the freedom to refactor without the tests adding additional friction.

Let’s look a little bit at the ‘shape’ of both a reducer, the elm architecture and the decider pattern. I am wondering if it’s also just a very natural pattern coming from functional programming.

2026-03-31: … to be continued …

Decider pattern

  • Decide method is for outputting a domain event based on an incoming command or event.
    • Type signature: Command -> State -> List<Events>. It takes a command and state and returns a list of events.
      • Nice that means more than one thing can happen when something changes?
  • Evolve method is for changing the state based on the current state and the incoming event.
    • Type signature: State -> Event -> State
  • WIP implementation of decider pattern in repository

Footnotes

  1. https://thinkbeforecoding.com/

  2. https://thinkbeforecoding.com/post/2021/12/17/functional-event-sourcing-decider

  3. https://redux.js.org/ originally created by Dan Abramahov is a implementation of the reducer pattern. After he was inspired by The Elm Architecture. Which is based on this paper on functional reactive programming. I wrote about Elm in 2017: https://infi.nl/nieuws/why-i-became-an-elm-evangelist/

  4. https://www.karlvanheijster.com/blog/22/06/testen-via-de-voordeur/