The Three Little Pigs with DDD and clean architecture
My tech talk, fairy tale sources: 1, 2, 3, 4.
Java 17, Groovy + Spock, Kotlin, Maven, Spring
Web app
App starts as an ordinary web app for
spring.main.web-application-type=servlet
Available operations:
- Build house:
POST
localhost:8080/houses
Possible values for{ "owner": "VERY_LAZY" }
owner
:VERY_LAZY
LAZY
NOT_LAZY
NOT_LAZY_ANYMORE
- Verify the house state:
GET
localhost:8080/houses/{id}
- Blow house down:
DELETE
localhost:8080/houses/{id}
There is a dedicated Postman collection with all these operations already defined: adapters/src/main/resources/3Pigs.postman_collection.json
Console app
When
spring.main.web-application-type=none
app prints the whole story in the console.
EventStorming
An example.
Big Picture
Design Level - commands, rules & actors
Design Level - naming aggregates
Possible improvements
House
could have mechanisms for rebuilding- Story can be extended - currently there is nothing about wolf climbing through the chimney and pigs lighting the fire
- New
House
method, e.g.litFire
- New
BigBadWolfService
method, e.g.comeDownTheChimneyOf
- Event, e.g.
WolfStartedClimbing
instead ofWolfResignedFromAttacking
, new event fromHouse
, e.g.WolfEscaped
(when burns in the fireplace) WolfStartedClimbing
should call bothlitFire
andcomeDownTheChimneyOf
in a proper orderWolfEscaped
should result in knowledge sharing
- New
- Full Event Sourcing -
House
can be built just from events, no snapshots in the current form