๐ Info: Done at day 3 / 5 of Domain Models in Practise, Nov 2020, given by Marco Heimeshoff โข @Heimeshoff.
๐ท๏ธ Tags: #Architecture #CQRS #Command-Query-Responsibility-Segregation #Event-Sourcing #DDD #Domain-Driven-Design #Domain-Modelling #Semantic-testing
Company: Cinemarco's Quality Reservation System (CQRS ๐) :
- 100 movie theaters in Europe.
- Seats selectable and reservable (before actual booking).
โ๏ธ Instructions: use TDD, use Command as input, YAGNI, Semantic testing (Given(events); When(command); Then(events)
).
๐ก Tips: Get momentum going and start building everything in one file and only when it gets a bit messy, extract classes into files and folders. Here is a nice video to elaborate: Elm Europe 2017 - Evan Czaplicki - The life of a file.
Tasks:
- A Customer reserves specific seats at a specific screening (for simplicity, assume there exists only one screening for the time being). If available, the seats should be reserved.
- The user will be informed, if not all seats from the reservation are available.
- Remove all primitive data types from the domain. Use only Value Objects and Entities within the domain.
- Bonus points: Make illegal states un-representable
Tasks:
- Refactor the previous test so that the command handlers use EventSourcing as a persistance mechanism. Check Assertions on the state.
- Publish the Events and test purely with Events and Commands, no dependency on domain state in your tests is allowed.
- If no booking happens within 12 minutes, the reservation is cancelled.
- Reservation is only possible up to 15 minutes before the screening.
- The reservation system calculates the total price of the reserved tickets (๐ง TODO)
- Additional behavior: When a second customer tries to reserve already reserved seats, the system treats them as unavailable
Scenario: The customer wants to see the available seats of the screening, chooses from the list which ones to reserve and gets informed about success or failure of the reservation. The reservation is only possible up to 15 minutes before the screening.
Tasks :
- Build a read-model that supports the user with the required information. Write a test to ensure, given the past events, when a query is issued the expected response is delivered.
- Write two tests to ensure each business rule from the scenario by only using the commands and events in your test.
- Write an "integration" test that uses only commands and queries, no events to check the whole business behavior of the system.
- Bonus-behavior: If no booking happens within 12 minutes, the reservation is cancelled. Super duper bonus: Implement a way to send a notification
https://gitlab.com/heimeshoff/domain-models-in-practice-2020-11-30