This video explains object-oriented design of a Restaurant Food Ordering and Rating system from list of problems on CodeZym.
Problem details : https://codezym.com/question/5
This question is asked in SDE-1, SDE-2 and Senior Software Engineer interviews.
This is a Java machine coding solution which is tested in a multithreaded environment on CodeZym.
Link to blog with code: https://bit.ly/3RYJ3ra
Feel free to reach out to me on LinkedIn: https://bit.ly/45ZeWmU
Design patterns used: Observer Design Pattern and concepts from strategy design pattern.
Thread safe data structures used: ConcurrentHashMap, ConcurrentLinkedDequeue, AtomicInteger
Problem statement:
Write code for low level design (object oriented design) of a restaurant food ordering and rating system similar to food delivery apps like Zomato, Swiggy, Door Dash, Uber Eats etc.
There will be food items like 'Veg Burger', 'Veg Spring Roll', 'Ice Cream' etc.
And there will be restaurants from where you can order these food items.
Same food item can be ordered from multiple restaurants. e.g. you can order 'food-1' 'veg burger' from burger king as well as from McDonald's.
Users can order food, rate orders, fetch restaurants with most rating and fetch restaurants with most rating for a particular food item e.g. restaurants which have the most rating for 'veg burger'.
Your solution should implement below methods :
Method : init(Helper05 helper)
Method : addFoodItem(String foodItemId, double price, String foodItemName)
Method : addRestaurant(String restaurantId, List[String] foodItemIds, String name, String address)
Method : orderFood(String orderId, String restaurantId, String foodItemId)
Method : rateOrder(String orderId, int rating)
Method : List[String] getTopRestaurantsByFood(String foodItemId)
Method : List[String] getTopRatedRestaurants()
Note :
Your code will be tested in a MULTI-THREADED environment, so use thread safe data structures and handle synchronization properly.
method call to rateOrder() will never be done concurrently with
getTopRatedRestaurants() or
getTopRestaurantsByFood(String foodItemId) : for the same foodItemId in given orderId
This is done to keep system state consistent and also test accurately in a multithreaded environment.
There will be at max 50 food items, at max 10,000 restaurants, and each restaurant can sell at max 25 food items
Rating for unrated restaurants or food items should be considered 0
when you rate an order it will count towards overall average rating of restaurant as well as average rating of restaurant for that particular food item.
when you are rating an order e.g giving 4 stars to an order then it means you are assigning 4 stars to both the food item in that restaurant as well as 4 stars to the overall restaurant ranting.
Ratings will range from 1,2,3,4 or 5 stars, 1 being the worst and 5 being the best rating.
Average ratings are rounded down to 1 decimal point, i.e. 4.05, 4.08, 4.11, 4.12, 4.14 all become 4.1 and 4.15, 4.19, 4.22, 4.24 all become 4.2
List of topics for this question:
Design a food delivery app
Design a food rating system
Design a food app
Food delivery app low level design
design a food ordering system
Food ordering app
Design swiggy
Design zomato
Design doordash
Design uber eats
Design uber eats app
Swiggy lld
Zomato lld
low level design
object oriented design
design patterns
Strategy design pattern
Observer design pattern
Strategy pattern
Observer pattern
Java
Machine coding
design patterns in java
lld system design
lld interview question
lld interview
lld & hld system design
low level system design
machine coding
machine coding round
machine coding interview
object oriented programming
Информация по комментариям в разработке