← Graph

Business logic in Ruby

talk 22 connections

Talk at wroclove.rb 2019 by Andrzej Krzywda (Arkency). A personal journey from Java's Plain Old Java Objects through Rails' Active Record coupling to splitting aggregates from read models, presented as three concrete implementations of a JIRA-like issue state machine: (1) using Arkency's aggregate_root gem with event sourcing inside the aggregate, (2) a polymorphic implementation with one class per state that returns a new instance on transitions and moves event publishing/sourcing into the command handler, and (3) a duck-typing implementation using respond_to? checks, shrinking the state machine to five small classes. Argues business logic is almost always about state machines, pure business objects shouldn't be infected by libraries or frameworks, and persistence (events or Active Record) can be plugged in later. Announces that Arkency's 'aggregates' repository — previously private and used in the Rails Architect Master Class — has just been made public on GitHub with shared tests and mutation-testing setup, and invites the audience to contribute new implementations.

type
talk
talk Business logic in Ruby
about
The talk walks through multiple implementations from this repository and announces its public release.
talk Business logic in Ruby
about
State Machine concept
Central claim: business logic is mostly about state machines; the JIRA issue example is a state machine.
talk Business logic in Ruby
about
Aggregate Root concept
First implementation uses the aggregate_root gem and the aggregate-root pattern from DDD.
talk Business logic in Ruby
about
Active Record concept
Discusses the coupling and 'infinite API' problems of inheriting from ActiveRecord::Base.
talk Business logic in Ruby
about
Krzywda frames his ideal (business classes free of library imports) through the Java POJO tradition.
talk Business logic in Ruby
about
Arkency adopted DDD terminology ('aggregates') for their business-logic classes.
talk Business logic in Ruby
about
Duck Typing concept
Third implementation uses respond_to? checks as a duck-typing style of dispatch.
talk Business logic in Ruby
about
Second implementation has one class per state, inspired by Szymon Kulec's functional aggregates.
talk Business logic in Ruby
about
Describes splitting Active Record models into decision-making write objects and display-oriented read objects.
talk Business logic in Ruby
about
Event Sourcing concept
First implementation uses event sourcing via aggregate_root; later implementations move events out of the aggregate.
talk Business logic in Ruby
about
CQRS concept
The read/write split motivates reading via Active Record and writing via pure aggregates — a CQRS shape.
talk Business logic in Ruby
about
First implementation relies on Arkency's aggregate_root module for event sourcing.
talk Business logic in Ruby
about
JIRA tool
The aggregate example in the repository models JIRA issue states and transitions.
talk Business logic in Ruby
about
Mutant tool
The repository includes a mutation-testing script using Mutant, which exposed flaws in the modeled state machine.
talk Business logic in Ruby
about
Narrative starts from the early Rails experience of inheriting from ActiveRecord::Base.
talk Business logic in Ruby
about
Ruby tool
All implementations are in Ruby; discusses idiomatic Ruby (duck typing).
authored
Business logic in Ruby talk
Krzywda introduces himself as both organizer and speaker and delivers this talk.
from_talk
Business logic in Ruby talk
Central thesis stated explicitly in the talk.
from_talk
Business logic in Ruby talk
Refactoring recipe presented in the talk.
from_talk
Business logic in Ruby talk
Recurring principle driving the progression of implementations.
from_talk
Business logic in Ruby talk
Explicit call to action at the end of the talk.
talk Business logic in Ruby
presented_at
Talk delivered at wroclove.rb 2019.

Provenance

Created
2026-04-17 16:17 seed
Read by
29 extractions