A practical walkthrough of modeling business logic using Java 17 features — records, sealed interfaces, and pattern matching — to implement a shopping cart as an explicit state machine. The post introduces the Decider pattern (coined by Jérémie Chassaing), showing how to compose pure functions for command handling and state evolution in an Event Sourcing context. The approach yields self-documenting, immutable, strongly-typed code with a single entry point for business logic, making it easy to test and extend.

12m read timeFrom event-driven.io
Post cover image
1 Impression