Friday, December 27, 2013

Object oriented design for a Restaurant

New Post I have done another OO-design for slightly different restaurant model here. You might check out that independent of this post.

Let us do the OO-design for a Restaurant today. Let me first describe how the restaurant we want to model works. These are the different actors in the model and i have listed the different actions against each actor

* Customer
  • Selects the dish from the menu and call upon a waiter
  • Places the order
  • Enjoys his meal once the dish is served on his plate
  • Asks for the bill
  • Pays for the services
* Waiter
  • Responds to the customers calls on the tables he is waiting
  • Takes the customer's order
  • Places the order in the pending order queue
  • Waits for the order ready notifications
  • Once notification is received, collects the dish and serves the dish to the corresponding customer
  • Receives the bill request from customer
  • Asks the Cashier to prepare the bill
  • Gives the bill to the customer and accepts the payment
* Cashier
  • Accepts the prepare bill request from the waiter for the given order details
  • Prepares the bills and hands it over to the waiter
  • Accepts the cash from the waiter towards the order
* Chef
  • Gets the next order from the pending order queue
  • Prepares the dish and push the order to finished order queue
  • Sends a notification that the order is ready
Please take a look at the Coffee Shop Design  as the restaurant design we are attempting here is derived from that. The differences between a Coffee shop and Restaurant are
  1. In  a coffee shop there is no waiter. Customer selects the dish and directly places the order with the cashier. In a restaurant there is the waiter who handles all the interaction with the customer. 
  2. In a coffee shop, customer upon getting notified that the order is ready, he collects the coffee himself. He waits for the order ready notification. In a restaurant, waiter waits for the order ready notification and once ready serves the dishes to the customer.

Object oriented design for a restaurant
OO design for a restaurant


Above is the class diagram for the restaurant we described above. To keep the matter simple i have assumed certain things like customer not changing his order once placed, customer not cancelling the order, unlimited queue size for pending queue and finished queue. However accommodating these exceptions is relatively easy. Just like the Coffee shop design here also there is asynchronous nature to the order processing which can neatly handled via messaging.

2 comments:

  1. How the queue is managed? Means Chef wait or what...Who tells the chef to process the request....Please explain as this is used in many of the designs

    ReplyDelete
  2. Thanks a lot for sharing the short post in your blog page. online ordering website for takeaways It is truly great and very helpful piece of information. It's really nice and informative post. thanks for sharing...

    ReplyDelete