Giter Site home page Giter Site logo

clean-architecture-workshop's Introduction

Clean Architecture Workshop

This repository is created to be a workshop codebase to learn the Clean Architecture.

Workshop Scenario

In this workshop we will implement a Cinema System to support ticket purchasing use case.

Cinema System

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.

Screenshot 2567-03-27 at 11.55.59 cinema-seats

User stories for ticket purchasing use case

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.​

Code base

In this repository, we already provided some key entities and classes to save time crafting them.

Class diagrams of some key entities

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()
    }

Initial data

Some data have be put into the key entities to setup movies and showtime data. You can see code to initialise data in Repositories.

Theaters cinema-seats

Movies cinema-seats

Showtimes cinema-seats Note:

  • 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

TODO

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

  1. 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
  2. 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. Screenshot 2567-04-03 at 14.56.10

Other Branches

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.

clean-architecture-workshop's People

Contributors

rachanee-tw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.