This repository is created to be a workshop codebase to learn the Clean Architecture.
In this workshop we will implement a Cinema System to support ticket purchasing use case.
This may be an example user interface of a cinema system when a user try to search for a movie and book a show time.
As a customer,
- I want to see now-showing movies.
- I want to search movies by title.
- I want to see details of a movie, then view its showtimes, available seats, and pricing, so that I can select preferable showtime and seats.
- I want to purchase ticket by paying with my default payment method and get booking detail for reference.
NOTE:
- Now-showing mean having showtimes between now to the next 15 days.- Let assume that the customer has an account and logged in.
- Customer have setup default payment method.
In this repository, we already provided some key entities and classes to save time crafting them.
classDiagram
ShowTime <-- Movie
ShowTime <-- Theater
ShowTime o-- Seat
Booking <-- ShowTime
Booking <-- Seat: which seats in the showtime\nthat the booking reserved
class Movie{
+ Guid Id
+ string Title
+ string Description
+ DateTime EndTime
+ TimeSpan Length
}
class Theater{
+ string Name
+ int NumberOfRow
+ int SeatsPerRow
+ int SeatPrice
}
class ShowTime{
+ Guid Id
+ Movie Movie
+ DateTime StartTime
+ DateTime EndTime
+ Theater Theater
+ List<Seat> Seats
+ ReserveSeat(string row, int number) Seat
}
class Seat{
+ string Row
+ int Number
+ int Price
+ bool IsAvailable
+ Reserve()
}
class Booking{
+ Guid Id
+ ShowTime ShowTime
+ List<Seat> Seats
+ int TotalPrice
+ string CustomerAccountId
+ CompletePayment()
}
Some data have be put into the key entities to setup movies and showtime data. You can see code to initialise data in Repositories.
- There are some movies having past showtimes and some movies having no showtimes. This to demonstrate the GetNowShowingMovies method.
today.AddHours(19.5)
= Today 19:30
You may see that currently the codebase is incompleted. Most of classes be put in a temporary folder CleanCodeApp.Domain/ToBeStructured
and most of them have only properties defined but methods. Meaning there is no logic to solve the user stories yet.
So, In this workshop you have to
- Structure classes in proper layer/folder.
- Moving classes around may cause issue of missing reference. You can run command to add project reference to allow referencing class from other domain. For example,
dotnet add tests/CleanCodeApp.Application reference source/CleanCodeApp.Domain
- Moving classes around may cause issue of missing reference. You can run command to add project reference to allow referencing class from other domain. For example,
- Implement logic to GetNowShowingMovies, GetShowTimesByMovieIdAndDate and CreateBooking. You have to consider where to put the logic. You may put it in existing class or create a new class for it.
There are 3 branches in this repository, which are
- main (this branch) : the workshop workspace. It consist of incompleted code in an improper layers that require architecturing and implementing to acheive the system requirement.
- n-tier_architecture : a working example that implemented using the N-Tier architecture to solve the problem. We can learn the disadvantages of dependencies on external parties from this branch.
- clean_architecture : a working example that implemented using the Clean architecture to solve the problem. We can learn this at the end of the workshop to get the idea of how to structure and implement logic in Clean style.