GithubHelp home page GithubHelp logo

aggregates's Introduction

Aggregates

An experiment of different aggregate implementations. All implementations must pass same test suite: arranged with commands, asserted with events.

Experiment subject

Quite typical workflow of an issue in a popular task tracking software (Jira).

workflow

Existing experiments

Classical example

source

  • probably most recognized implementation (appeared in Greg Young's CQRS example)
  • does not expose its internal state via reader methods
  • testability without persistence (just check if operation yields correct event)

Module source: https://github.com/RailsEventStore/rails_event_store/tree/5378b343dbf427f5ea68f7ddfc66d6a449a6ff82/aggregate_root/lib

Aggregate with exposed queries

source

  • clear separation of state sourcing (with projection)
  • aggregate not aware of events
  • handler queries aggregate whether particular action is possible

Aggregate with extracted state

source

  • aggregate initialized with already sourced state

Functional aggregate

source

  • no single aggregate, just functions that take state and return events

Polymorphic

source

  • domain classes per each state
  • no messaging in domain classes
  • no id in domain class
  • invalid state transition cared by raising exception

More: https://blog.arkency.com/make-your-ruby-code-more-modular-and-functional-with-polymorphic-aggregate-classes/

Duck typing

source

  • domain classes per each state
  • no messaging in domain classes
  • no id in domain class
  • invalid state transition cared by not having such methods on objects (duck)

Aggregate with yield

source

  • yield is used to publish events (no unpublished_events in aggregate)
  • aggregate repository separated from logic

Aggregate with repository

source

  • aggregate is unware of infrastructure
  • aggregate can built itself from events (but it could be recreated in any way)
  • aggregate keeps the state in PORO way
  • aggregate registers events aka changes
  • aggregate provides API to read registered events
  • Infrastructure (through repository in this case) is responsible for building/saving the aggregate so it could be done in any way - Event Sourcing, serialization etc

Roles/DCI

source

  • better mental model by not having separate classes per state
  • one object which changes roles
  • extend(Role.clone) is used as Ruby ignores subsequent extend with the same module

PORO with attributes

source

  • clear separation of state sourcing (with projection)
  • aggregate not aware of events
  • aggregate object is still responsible for holding invariants
  • no id in domain class

aggregates's People

Contributors

mostlyobvious avatar pjurewicz avatar mpraglowski avatar andrzejkrzywda avatar swistak35 avatar jandudulski avatar

Stargazers

Łukasz Reszke avatar James Brennan avatar Jan Król avatar Marcin Klawitter avatar  avatar Tom Donarski avatar Eric Gross avatar  David Gillis avatar Marcelo J. Both avatar Brenton Morris avatar  avatar Dave avatar Erik Shestopal avatar Pavel  Akulich avatar Grub avatar Khalil Stemmler avatar  avatar thinkcerca-cto avatar Michael Fairchild avatar Bruno Antunes avatar rpCal avatar Buts Johan avatar Michał Bury avatar Mateusz Urbański avatar Łukasz Żukowski avatar Igor Zubkov avatar Rustam Ibragimov avatar White Rabbit avatar Mykl Clason avatar  avatar Chris Coetzee avatar Amarnath Nambiar avatar David Gerő avatar Karol Burdziński avatar Lekë Mula avatar David Montesdeoca avatar Anand Dhillon avatar  avatar Lauri Jutila avatar Jaigouk Kim avatar Andrea Dal Ponte avatar Grégory Faruch avatar Thomas Klemm avatar Murugan avatar Ritchie J. Latimore avatar Chris Olstrom avatar Justin Workman avatar Mark Frost avatar Denis Ilyasov avatar Ilya Osotov avatar Anna Buianova avatar Alex Klyanchin avatar Pavel Kozlov avatar Thomas Jaskiewicz avatar  avatar Mikita Pridorozhko avatar Iqbal Rifai avatar Philip Lambok avatar Jan avatar Benji avatar Oluwasegun Adeleye avatar Adrian Resler avatar Thiago F. Lins avatar Oleksii Drobiazko avatar Andreas Robecke avatar Pavel Bonda avatar Paweł Stiasny avatar Charles FD avatar Alexander Presber avatar simo sentissi avatar Alexander ADAM avatar Tomasz Łoszko avatar Dawid Leszczyński avatar Glutexo avatar Alek Malaszkiewicz avatar Wojciech Korzeniowski avatar Michał Zając avatar Wojtek Wrona avatar Jarosław Siedlarz avatar Jaroslav Toropygin avatar

Watchers

 avatar Paweł Kondzior avatar Jakub Rozmiarek avatar Szymon Fiedler avatar Marcin Domański avatar  avatar Tomasz Patrzek avatar  avatar James Cloos avatar Alex Klyanchin avatar  avatar Piotr Romańczuk avatar Tomasz Wróbel avatar Wojtek Wrona avatar Jaroslav Toropygin avatar Tomasz Stolarczyk avatar Oluwasegun Adeleye avatar Łukasz Reszke avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.