Book My Show || Low Level Design Code || Amazon Interview Question Solved!!
HTML-код
- Опубликовано: 21 ноя 2024
- Hi,
In todays video I have discussed in detail the entire code for Low level design of movie ticket booking system. I have used SOLID design principal along with several oops concept to come up with a robust design for the system. I have also talked about possible extensions of the problem and how to generalise the solution to solve for any event ticketing system.
This is the code file: drive.google.c...
As usual, if you would like to be a part of free mock interview series please follow my Instagram handle
To connect with me:
Instagram: / dynamic_coder_18
LinkedIn: / soumyajit-bhattacharya...
Telegram: @sdeinterviewpreperation
Message me here regarding the same.
Please do like and share this video. Subscribe to my channel and hit the notification bell !!!
Thanks everyone!
#amazon #arcesium #deshaw #google #low #level #design #lowleveldesign #soumyajit #bhattacharyay #bhattacharya #system #design #faang #facebook #code
system desgin, facebook, apple, amazon, netflix, google, arcesium, de shaw, low level design, soumyajit bhattacharyay
While booking seat, using locks at the right level (so that the entire application doesn't get locked), timeout for a lock, asynchronous payment processing is the main reason why this question is usually asked.
Identifying the entities are good starting point. 👍
List seats being a part of Show class and not Audi class -> the explanation and the thought process behind it was amazing. Thank you for clarifying the same
He is definitely a Indian techie monster. Nice tutorial.
Hi, Great Video.
Some points which i faced or asked to implement -
1) Use of SOLID principle.
2) Core logic of some important class.
3) Extensibiliity for some extra features in future - in this case - Coupons, Offer, Cancellation/Modification for events.
4) Iteraction between some classes.
Explaination if possible, a little slow.
Were you able to implement all of the requirements considering limited time ? How does the interview perceive that if we are not able to complete everything
@@akshaysachan9592 Two parts here - Need of overall discussion of these kind of topics from person to the interviewer, side along asking interviewer if he or she want to move in that direction.
Second Part - It is not important to wholly focus on to give complete solution. but How strong fundamentals were, Discussion of overall ideas and wether interviewer got idea If a person will able complete it, if more time was given.
One bonus point - If interviewer is not giving direction, and just listening. It is your job to navigate the solution.
Overall a great explanation. We shouldn't be spawning out separate classes for each Role (ex:admin) they are going to play, that has to be abstracted out and made as a separate user management module( or access control module). Tight coupling a user with a role is not scalable. often we would like reassign the user a different role so these two should be separate entities and should have a m:n association among them.
@4:27 A better argument could be, when a ticket is booked, it is booked for a particular show. So, in the show, one can have all the seats instantiated, and used.
You have splendid communication skills
Thanks for the feedback!! Really appreciate it!
You have amazing communication and a grasp of the topic.
I have just one piece of advice: Break it. Break the files and classes. That is all we want. Thank You!
Okay spammers, I'll never open flixzone or whatever 😂
Great video, thanks!
1. What is the general format one should adapt to answer in LLD interview?
2. Are we expected to make Class Diagram and Use case diagram in the beginning?
3. Are we expected to write internal logic of how booking is done, what if booking is full and so on?
It all depends from one round to another, one interviewer to another. In my interviews I had been asked all three types, making classes, APIs functions and their interdependencies, then in some of them was asked to implement it end to end and in some was asked to just implement a couple of functions
felt confident after watching this video.
Great work Soumyajit.. your LLD videos are the best low level design courses among those I have seen..
Thank you so much..
Good video! I specially liked the ending part where you explained how it can be extended to any kind of booking system not just movies. That was really good.
I am thinking of switching to a SDE-2 role in a year and wanted to see how LLD looks like. Great video man! I am confident I will be cracking something great in a year! 😇
Have you bro?
@@HimalayGoyani No bro, feeling settled here, I am upskilling according to project requirements, getting good hikes year on year, still I will consider switching if I don't get promoted this year, in SAP Labs now
@@unlockyourfinance bro don't get too comfortable :)
Doing great.I would suggest to increase frequency of LLD.
Thanks for the suggestion. Yes i will be uploading the parking lot lld video soon!!
@@SoumyajitBhattacharyay I still cannot find more videos on lld
U r helping lot of people to be well prepared for the interviews.Good job and u will get lot of good will
your low level videos are clear and precise.. Keep making videos..
Great video,
Soumyajit.
One question though, in interviews they don't ask to implement the reponsibilities of each entity/actor class? If they ask for a working prototype solution, we need to implement all these apis correct, using some in-memory Data-structures.
Please make a LLD video where your cover the implementation details of the responsibilties/apis.
You can have repository class and we can use maps as our data stores , and we can refer this repository from service class. This will make implementation easy during interviews and works fine.
bro, you make amazing video, can't thank you enough, you have the best OOP interview practice
Thanks for the great video..! However one feedback: cityShowMap shouldn't be a part of Movie, as it doesn't seem to be a scalable approach while preserving into DB.
A very good explanation Soumyajit . I really like the extension part which you explained in the end.
Great efforts and crisp and short video
Straight to the point..brilliant explanation!
Hi Soumyajit, it very good explanation fro coding front.
Can you help to understand the database front also like what all tables , how table hold mappings and more
Awesome!!! Please keep making such videos... It would be of great help,if you start by showing the class diagram and then moving on to the code part.
best tutorial of low level design with great explanation and also with code...
Thanks so much glad you liked it!
Thanks for adding additional details of using inheritance to extend this architecture for booking events and other
Today from nowhere youtube suggested me your channel ... was bored .. and just decided to watch for couple of minutes ... but already finished 5 videos 😂😂...Great video bro .. really appreciate your hard work ... I think so ...I will end up watching all your videos by today itself 😂💯💯
Thats super cool! And good to see that the algorithm is picking up some of my videos 😄.
Thanks for watching and really appreciate thr feedback!! 😄
@@SoumyajitBhattacharyay Your low level design skills are god level 💯💯💯💯... plus explanation also . 💯💯
@@carpediem9407 thanks 😄
Helped me a lot ! thank u so much , gave me the clarity I needed 😇
Thank you for your efforts!!! This is the very first vedio I have seen from you channel, I will surely watch all the vedioes on LLD.
I am not convinced with using the same design for something other than bookmyshow, it very obvious that both the product might evolve in different ways, and unnecesasry we have to keep an indentifier to track which fields belongs to what product and not foe another product.
btw. good explanation
great video and explanation loved it....
please do the design of Airline/flight booking system.........
Thanks for the video. The best part is you have coded what you design. Can you also include or talk about the database schema ?
That would cover most of the design perspective of the app.
Great Video. Keep up the good work going brother.
Very well explained !!
First of all thanks for the efforts. :). One correction. If you are adding searchobj in User Abstract class, then for your admin class you will be breaking liskov substitution rule as for admin it doesnt make sense to have searchobj.
You've created a circular dependency between Show , Cinema & audi. How will toString() work in this case? It will lead to an infinite recursion. Is this correct design or an anti-pattern?
Hi Soumyajit . This is not to devalue your work . but my observation is that most of the lld on this channel or else where are using same set of design patterns like decorator and strategy. i am not finding the designs very elegant . LLds should be about how well are we choosing our design patterns and data structures. Stiil great work . Thanks
Very informative. Please design more lld's.
God level explanation
Great video 🔥🔥 , I would like to meet you in person !! Great Mannn 🙌👏
macha diya dada !!! thankyou so much.
Hey Soumyajit, I would actually like to see one code with the whole implementation and your thought process.Since sometimes which data structures(list, hashmap) to store information varies while implementing.Thanks!
Subtle Explanation! Just curious to know where do you learn this stuff from! Just asking though but waiting for your next video in this series.
Thanks for the great video. Is concurrency handling a part of LLD?
hi,
Couple of doubts :
1) why cinemaHall inside show?
2) why price for every seat?
3) how will you implement "public List getMovies(Date date, String city);" in BMSService?
I understand theres no single right answer, but would like to know the changes needed for 2 and 3.
Thanks
According to my understanding :
1) Even I didn't get any usecase of CinemaHall in show. If you found any let me know.
2) Because seats are of different type defined by SeatType enum. And different type will be having different price.
3) BMSService has List. So in to begin with we can filter out the cinemaHalls on the basis of city in getMovies method. Then on filtered CinemaHalls we can call the CinemaHall's getMovies method.
Any different thoughts? I am up for a discussion. :)
Thanks, man! this is so helpful and crisp!
Wow! Worthwhile Content, Neat Presentation.
Excellent video. Great work 👍
Nice explanation. Keep doing this. And encourage others.
Great Explanation. Keep posting such useful content.
Excellent
Amazing content, well explained
can u share resources u used to learn this stuff and btw LLD videos are dope plz post more videos and can un answer the questions for OS u mentioned
Surr definitely i will do that.
Thanks for such encouraging feedback!
I have a lot more lld videos in pipeline.
Stay tuned to watch them!!
@Somyajit , IMHO the parent entity should'nt be storing the references to the child entities (Unless they belong to the same aggregate). For example : ShowService and AudiService might be deployed as two separate microservice altogether , in those scheme of things AudiService should not store the reference to the Show, rather Show as a child entity should store the reference (as a client reference id if you will) to Audi entity. Even in case you STILL want to store the reference of child entity with parent it should be just the primary key and not the object. Let me know your thoughts on this!! :)
EDIT: Just to explain better , if we will store reference to Shows in Audi entity , this will introduce hard coupling between the two services , Show service going down would mean , I can't even create an Audi!
Ofcourse a fresher type of answer. No extensibility in the system, just coded the requirements. Cannot add any new type of booking, like what about if I want to book a theatre show, Virtual meeting, party or what ever. Just thinking about that changes every goddanm thing in this design/class. People please get your design reviewed by any person. Low level design does not mean coding the solution. It means you have to decide the design. Please get your solution reviewed before posting on youtube as a good solution. At the end of the video he himself mentioned clearly that he will be changing almost everything of core code, I am not sure how he did not realise this thing and saying we will just change this and this and this and this .. omg.
great explanation
very crisp and perfect vdo 😋
CinamaHall class has getMovies method which only based on date why not city?. As its for particulat cinema hall then we shd know for that cinema hall get me all the movies on that date and city right?
Great Work! Could you make LLD video of Uber/Ola.
Hi, thanks for this playlist. Just stumbled on your channel. Great work
Glad that you liked it! .do subscribe and hit the bell notification so that you remain notified.
And don't forget to share with your friends
Great video just minor doubt for admin user he can add Show right so when he wants to add Show
So he will give us the show object and addShow API will add the Show at the database but this Show will have all the information like at which cinemalhall, of which movie type, timing and on which Audi of the particular cinema this show will be placed.
if I observe carefully there is an API in cinemalhall which gives me the list for particular dates, now when this API will give me list if I get one show object it has all the information of the show at which cinema hall this is available, what is the movie and everything. i am confused like Show has a cinemal hall object and Cinemal Hall has list which internal have list when you try to store show information in the database Show will be a huge object right?
Great work
Inheritance sucks. Composition is the way to go
Great content 👌
Great work man 👏
Great work
Most important part of this question is how to avoid long locks while booking payment is going on, or not use lock at all but in that case two users can book same seat, so how to manage that concurrent case.
@soumyajit great work bro, Amazon Sent me some study material before interview, where your LLD playlist is included for preparation'
Is that so? That's awesome. 😛
@@SoumyajitBhattacharyay yup bro, yes its awesome your work is being recognised and that's how I landed here 😉 keep grinding
@@sahildhiman7675 can you please share your experience as I am also having interview with amazon
Well done 👍
Hi Soumyajit,
Thanks for this video, it is very helpful. I have one doubt that whether we should start by creating API class first or Entity classes first like (Person, Movie, Show, Screen, Seat) and then build API class. Any input from others will also help.
You should be knowing both. And you can ask this question with the interviewer for which one to start with.
Hi Got some confusion..in CinemaHall class,List audiList one of d field,... then in Audi class,List shows...again in Show class, Cinemahall cinemaHallplayedAt.....its looking like cyclic?..which type of relation it is?............i mean should we define fields in a class as child fields(like for CinemaHall class, List audiList is type of child field)...but in Show class, Cinemahall cinemaHallplayedAt, its looking parent field in a class Show....might my analysis & its looking into cyclic way..
I have the same doubt, it should not be cyclic as you can always derive some fields from the associated fields.
Got rejected in 1 company because of these mistakes.
How would you make sure that no two users end up booking the same seat?
I think it would have been better if you have just gone through a quick look of requirements, anyways it was great video as i am watching it after 3 years of upload👍
Since you spoke of 'strategy pattern' , how about making a small video on that and linking it here in the description?
Thanks!!
Yes absolutely. Not only that all of them I will be making it in an upcoming video series ♥️♥️
Do stay tuned
great content
u r great
So, when the admin wants to add a new show for a movie from where will he get the seats list?
Ideally, seatList should be in the Audi and in the show class we should just have a list/set of seats which were booked for that show.
CinemaHall getMovie and getShow api ,will probably call database/datastore to fetch details.So isnt it violating SRP here in CinemaHall?
I dont see why we need these api, we can have some cinemaManager type of class, that can handle this.That can talk to datastore and fetch results, why would we have this in CinamaHall Class?
The way you have movie search class, similarly you should have cinema search.It should do all this stuff. GetMovies in cinema and then filter by data and all apis.
These are just data types you defined.Actual interaction is not clear.How would u get List for audi?It has to talk to someone.That thing is missing everywhere
Hi Saumyajit,
Can we use any Design pattern to improve on the Search part?
We have defined 4 types of search in this case.
But when we add more EventLocation like a stadium for let's say cricket match,
we might need to a Sports wise search and so on.
In the Current case, we will need to update and existing class.
Can we add somehow add new search functionality just by adding a new class?
And Thanks for the Great Work Man !!
hey, I have a question, all these questions that you have solvedm you made the solution as stand alone aplication why haven't you provided a solution as web application, ie. having controller layer and apis and all, in most of the methods that you have defined in your actor clasees would have been residing in service class, and the entities will just be model classes.
In booking class,dont you think that Payment paymentObj; and and the parameter passed to makePayment should be of different types?Booking should have PaymentInfo object like txnid,amount etc. and makePayment should accept something like Payment which is credti card/debitcard etc.?
Do they ask to complete the entire design here with each of the implementation and
Main class.
Loved it... ❤
What are people saying? How is this a god-level explanation? This has a code smell. It has a circular dependency
Booking object should not contain totalAmount since it is already containing Payment object which have amount inside it ,correct?
How do u make sure two people wont book same seat
Bro,
A small doubt
Does LLD mandatory for Frontend Developers/Web Developers also ?
too good
How do we decide which method/behavior belong to which class. eg like getMovies() should be part of Movie class or Audi class? why certain list of maps are present in specific classes.
@Ritu Gupta, I have the exact question, did you got the answer to your question?
best
I would prefer the get methods of different concrete types to be in their own service.
What is Audi? Its little difficult to understand. The only Audi I know is car. :) Please let us know what is Audi
Audi means auditorium , in which the movie is shown
loved it
Some suggestions:-
1. Movie should not have cityShowMap as its member, however there can be api in Movie to return getShowsByMovie that returns this map.If we want to make search faster, we will look some other stuff if required.I dont see this map as a movie attribute.To improve search we can always see caching and all stuff before making changes at low level for this thing.
2. Similarly audi should not have List of shows. It can expose api to get active show of this audi.Or if we can ,we can have list of active shows instead of shows.But still i would not like to store list of shows with audi.Show can be separate class with audi id and movie id info.
Please let me know your thoughts
One thing, since this is from a perspective of LLD in interviews the focus will be to make everything in memory. So any caching technique will not be entertained.
Plus hacing said that think LLD to be a complete in memory implementation. That is the expectation out of these rounds for most use cases. Hence, we need to keep certain attributes in certain classes which makes most sense as per the given constraint.
For example a audi should be containing the information for the list of shows that is running as it is specifically the attribute of the audi.
As show time etc will vary as per a specific audi! And likewise for all the other things
@@SoumyajitBhattacharyay understood thanks.Since these are open ended questions.I think these are more of a discussions round than a question/answer:).Thanks for you efforts.
Absolutely true. They are extremely open ended. But as a general rule of thumb low level they test strictly Class design/ db design for the corresponding classes and while implementing they generally ask not to rely on db as a source and make a more of an in memory solution.
Highlevel on the other hand focuses on all the aspects about creating a robust system that can handle high tps etc.
long discussion.Just one query, you maintained map as i asked above as a private member, then why did not u maintain similar map in cinemaHall Class, instead there you choose to expose api instead of map?Can you explain why?it will clear stuff
7:45 What is the significance of searchObj in User class?
where price thing is done? like showing price of movie
For CinemaHall Class, there should be an IsActive Flag, in case the cinema is going through renovation, or it will be closed.
Awesome
Glad you liked it!
One point is left that is concurrency issue while many people booking tickets at the same time.
I had explained the same in some other comment here. Let me find that out snd pin it 😛
@@SoumyajitBhattacharyay one more question with LLD videos, we need some explanation or usage of Design patterns n SOLID principles in the LLD videos because not everyone use all design pattern in their porjects.
I have a doubt here, as Show class is having CinemaHall so this can be derived that this show is running in which cinema but Audi can't be derived here , like on which Audi the particular show is running.
According to my understanding : I don't think we even need the CinemaHall in Show. Audi class has list of shows, so from there we can know which Audi is playing what show and, CinemaHall is having list of Audi, from there we can get other information.
Any thoughts?