Search code examples
javaumlclass-diagram

UML class diagram for online reservations, need some assistance


For a school project I have to develop a website that handles booking-reservations for one vacation house. The idea is that the administrator can add customers to a CRM-system. Only then, customers can login with their chosen credentials. When the customer makes a reservation, it is up to the administrator to give it a status, which can be: ACCEPTED, REJECTED or VALIDATING. The last one is the standard status for every reservation.

Here the updated class diagram: enter image description here

While designing the UML class diagram, I found some errors. Firstly, for the project we wanted to have a list, available for the administrator only, filled with all reservations. But also a list, per customer, just for ease. Secondly, for the project a CRM-system. Which contains all data, reservations, customers, login credentials (hashed of course!)

Now, how do I imply that, to the class diagram?

Looking forward to your answers!

Firstly I tried to put all customers and reservations in 2 different ArrayLists, as seen in the attached image. But I wasn't sure how I could access them from the administrator perspective.


Solution

  • If your UML diagram doesn't include a ReservationSystem class, you're doing it wrong.

    Customer and Administrator should not own any lists. The ReservationSystem does. It should expose methods that allow different Roles to view, add, update, and remove instances of Reservation. The private implementation might use Java List; it could choose to use any other collection to maintain instances of Reservation in memory OR a relational database to persist them. The beauty is that users need not know or care how you choose to persist the data.

    Customer and Administrator are just different Roles. A Customer should only see their Reservations. An Administrator should be able to see ALL of them.

    Make your UML reflect these ideas if you agree.

    Here's how I might do it:

    enter image description here

    Here is the Plant UML text file I created to generate it:

    @startuml
    
    !theme vibrant
    
    title Reservation Class Diagram
    
        class Customer #LightBlue
        class Reservation #LightBlue
    
        class ReservationManager #LightBlue {
            reservationRepository
            findAll()
            findById()
            saveOrUpdate()
            remove()
        }
    
        class CustomerManager #LightBlue {
            customerRepository
            findAll()
            findById()
            saveOrUpdate()
            remove()
        }
    
        interface GenericRepository #LightBlue {
            findAll()
            findById()
            saveOrUpdate()
            remove()
        }
        interface ReservationRepository #LightBlue
        interface CustomerRepository #LightBlue
    
    
        class InMemoryReservationRepository #LightBlue
        class RelationalReservationRepository #LightBlue
    
        class InMemoryCustomerRepository #LightBlue
        class RelationalCustomerRepository #LightBlue
    
        enum Role #LightBlue {
            CUSTOMER
            ADMIN
        }
    
        ReservationManager *-- ReservationRepository : "has a"
        CustomerManager *-- CustomerRepository : "has a"
    
        ReservationManager -up-> Role : "uses"
        CustomerManager -up-> Role : "uses"
    
        Reservation "many" o-right- "1" ReservationRepository : "persists"
        Customer "many" o-left- "1" CustomerRepository : "persists"
    
        GenericRepository <|-left- ReservationRepository : "extends"
        GenericRepository <|-right- CustomerRepository : "extends"
        ReservationRepository <|-- InMemoryReservationRepository : "implements"
        ReservationRepository <|-- RelationalReservationRepository : "implements"
        CustomerRepository <|-- InMemoryCustomerRepository : "implements"
        CustomerRepository <|-- RelationalCustomerRepository : "implements"
    
    
    @enduml