For this application first we have to identify the data that needs to be saved and accessed, with that we will churn out entities that will take form of classes and use inheritance in case of relationship. After that based on the use cases we can design functions and events flow.
so here if we see the requirement defined for application :
-
There are customers who make reservation
-
There are tables for which reservation are made.
-
Waiters who will take orders.
-
Food Item that will be added to bill
-
Bill which has to be payed.
-
Order which contain list of food items ordered with quantity
So five entities i.e. classes needs to be created.
Now, since customer and waiter are person so we can create an abstract class with some common attribute like name, ssn, phone number, address e.t.c. and then we can inherit it to make customer and waiter class with their specific attribute like waiter id for waiter and no. of accompaniment for customer.
Similarly food item can be an interface which can be inherited in veg and non veg abstract classes which can further inherited in different food items available in restaurant.
Now, for holding reservation details we need to create a reservation table in db which contains details like :
1.reservation id
2.table num
3.customer id
4.waiter id
5.date and time
6.order
7.bill
Now, below are the possible use cases that I can sort out :
-
Make Reservation - For this use case from ui user will fill the details like time and no. of people for dinner reservation, based on that we will search in db for the availability of table with that capacity on that time. For this db query we can use table and reservation. If available, then we will send success response with table id to ui and then user can continue after filling his details like name, ssn e.t.c. and make reservation with confirmation button. With this we can generate a reservation num and save the details in that table with a waiter alloted to that.
-
Waiter login - this is simple login flow so nothing new here.
-
Waiter access to add order - Here at his home page waiter can select table (in case assigned to multiple table) for which he has to add order. Here on the ui we has to provide a search functionality
a) to search food items - so an event is made on click of search button which will call find query in food item db and return result. This result can be used by waiter and then click on add button after selecting quantity, we have
b) create an event to generate order or update order with those food item.
- Bill generation - When dinner is done then waiter can click on checkout button and then need to create an event which will create bill based on the order of that table and save it in database with waiter tip details :)
I have not created any class and function as based on programming language it changes but design will remain the same.
Now for error handling-
There can be multiple error as table not available, food item out of stock, total calculation at the time of bill generation and many other with technical errors like db query, logical errors.
Also , ui related errors like phone number not correct, ssn not provided e.t.c.