Very well explained. Could you please make a LLD video which emulates a real interview setup. Like how it start with a vague problem statement and the discussion about requirement details that follows between the interviewer and the candidate. Thanks for doing these videos :)
Very well explained, we can do one addition here as both user and book have barcode we can have a separate interface or class for barcode with helps in defining the barcode and assigning it.
Hey!! Thanks for the upload. 3:59 Instead of extending BookItem with Book. I feel we should prefer composition over inheritance? And in actual application it would be helpful for storing it as two tables. What do you think are the drawbacks for the below design? class BookInfo { String uniqueIdNumber; String title; List authors; BookType bookType; } class BookItem { BookInfo bookInfo; String barcode; Date publicationDate; Rack rackLocation; BookStatus bookStatus; BookFormat bookFormat; Date issueDate; }
My guess would be is-a vs has-a relationship. BookItem is a Book. Here, the subclass is a proper subtype of the parent class. And even in the requirements, it says that these BookItems are copies of a Book.
I also think that a composition would be better idea. We have hunders of bookItems, all of which belong to same bookInfo. It does not make sense to duplicate the information in each and every bookItem class object.
Great work Soumyajit, you're awesome!!! Just a thought though, we could have overloaded the getBook function in the Search class to take in 4 different parameters shown here rather than having 4 different functions. Lemme know what you think about this. Thanks & best wishes to you!! :)
Hi Soumya, one thing I wanted to highlight is that in the real interview we would need to run this and show some data. How would we write the driver code in best possible way? In actual interview even if your design is not that great but your code is working with data and all the features is more important. Becoz then we also have to provide the implementation for all the interfaces we defined.
That is not true at all It depends on the interviewer and what they want to see. In one of my interviews I was asked to write the entire implementation. In some I was asked to write just the implementation of one or two features. And in most, I was simply asked to write class design, db design, api contracts.
@@SoumyajitBhattacharyay Yeah agreed.. Many won't ask but many are there who ask. But I just gave it as a feedback.. Becoz I wanted your videos to the one stop solution for LLD. Anyways Np.
Great video! One question - Could the Search and BookIssueService be directly added to SystemUser class instead of adding both of them to its child classes i.e. Member and Librarian?
@@naveengarg7435 how exactly will it violate Dependency Inversion principle, could you please explain ? We will still be relying on interfaces for Search and BookIssueService functionality.
I believe the book Isuse service should not contain methods for issuing and reserving books. These methods belong to Lending class and Book reservation class. The book issue service is just a wrapper because we don't want to replicate the code to both member and librarian. But, this does not make the bookIssueService the owner of these methods. The owner still remains the lending class and reservation class. Now the book issue service may contain object of Lender and reservation which will call the lending and reservation methods or we may completely remove the book issue service and directly put these objects inside the member and librarian too make use of it. But, just because we want to remove code duplicacy, I believe it is wrong to change the ownership of method from lender and book reservation, assign it to a completely new class which is a book issue service.
In LLD interviews, is the expectation to write the entire code with logic? Or define the basic structure with the classes and their attributes and methods?
It was a great video, learnt a lot .Only have one question ,in an Interview whether the requirements will be given to us or we have to ask the interviewer about our queries regarding the requirements or we just have to assume the requirements? Thanks for answering in advance!
What about the methods of each class? What if the interviewers wants us to also implement relevant methods for the said classes, then how shall we practise the same?
I have a small doubt here, Why cannot we define the search and book issue service functions inside the Memeber class, since it will already be inherited by the User and Librarian class? This would also help us override the search method for eg. in case we don't want to show lost books to customer but librarian can still see it. Can we override the Search class methods from the Customer class in java ?
i guess writing algorithms and implementing data structures is not a part of LLD? i thought i would see i a complete working code, implementing search through binary search,storing in heap , and other implementations . rest the video was nice and contained all classes
Thank you so much. Excellent video to learn LLD. One doubt though. We are not storing BookIssueDetails anywhere. Does this mean we are storing BookIssuedetails in DB ? So if I have to search for the books issued to a user, how can I know that?
I think that there should be 1 table in the DB(relational) that contains issued books data like IssueId, borrowerId, dateTimeOfIssue, bookItemId, etc. So if you need books issued to a particular member, just query this table passing his ID. Hope I understood your ques right.
Hello, Thanks a lot for the video, its one of the best for explaining OO design paradigms. I find it a bit hard to gather how we are taking care of the fines though. Should the BookIssueService not have a list of BookLendings, so it can track all reservations/issues for one account?
can we use prototype design pattern in BookItem class ? so that every time when new copy of book is added in the inventory we only have to change few fields and persist data. Any views on this?
It seems that your solution doesn't take account list books which a systemUser currently has . Also which book is issued to which user is also missing.
Why we need SystemUser & Account as seperate classes..both can be merged into 1 class...right?.. as we will not do code duplication also & both classes has relevant data..
Book item list is defined in Library class. but for the search class to search for a book with a particular Author's name it needs a list of book items..can someone please tell me how do we pass this list?
Hi generally as a rule of thunb the is a and has a relationships are applied over real world objects. hence Book item is considered as the real world representation of the book here.
Hi, 1. How will you support edit,delete,update book item operations?Dont you think we use use Hasmap instead of List in library class to support these operations in constant time as edit,delete,add will result in updating data in Library class List. 2. How will this information be passed to search service so that it can update its data? 3.Why do we need to put searchService and BookIssueService objects in Member and librarian Class?Book issue service will take user and book while issuing a book,but it will not be called from Member class,right?We will not say Member.issueService.issueBook,it does not make sense.I mean we cannot show that interaction will classCode only. Let me know your thoughts?
1) How ever you may go ahead and use a hashmap, But be mindful as it is not required here. The edit, delete and update operations will not be done in memory. These operations will be done in persistent storage and hence a hashmap not required. 2) For performing basic CRUD operations we can have specific APIs that do the same, But with the problem statement in mind need to define the basic CRUD APIs. 3) The BookIssue service will be called from the member class. As per the requirements, the member should be able to issue books on their own. If you go and watch the use case diagram it will be come more clear as to which class should have access to which services. Hence it should be a part of the Member class as now, it will give the Member object (AKA the person who want to borrow the book) permissions to issue the book using the system rather than having to do that through the librarian. Apart from the Member the librarian should also have the scope to access the BookIssueService and the SearchService. Member should be given exact permissions to actually perform searches and issue book by self checkout kiosks. That is the whole point of the Library management system.You can go through my previous video to understand the interaction between the different actors to get an understanding of the scope of the system. Before writing the code, we should analyse all the work flows properly and then only start with their implementation.
@@SoumyajitBhattacharyay Thanks for quick reply.I am fine with point 1 and 2 raised above.But i still have doubts about 3rd point.So do we need to add methods of issue book and all in Member class also?Which will internally call Book reservation issue?Dont you think that it is not responsibility of user class to manage book issue/return and renew. Shouldn't this responsibility be separated from member class?
If someone give these requirements written in full sentences, i believe anyone can come up with their own LLD. The difficult part is understanding the ask and gather requirements.
Not true for the first part. True for the second part. I have seen way too many folks not come up with the design of systems even after getting the requirements. But true, coming up with the requirements that will happen over time when you are exposes to such scenarios at work. At work we constantly get such scenarios where we have to create the entire business requirement document also known as the BRD. It is something that cannot be tought and have to come with experience.
Very well explained. Could you please make a LLD video which emulates a real interview setup. Like how it start with a vague problem statement and the discussion about requirement details that follows between the interviewer and the candidate. Thanks for doing these videos :)
Very well explained, we can do one addition here as both user and book have barcode we can have a separate interface or class for barcode with helps in defining the barcode and assigning it.
Hey!! Thanks for the upload.
3:59 Instead of extending BookItem with Book. I feel we should prefer composition over inheritance? And in actual application it would be helpful for storing it as two tables. What do you think are the drawbacks for the below design?
class BookInfo {
String uniqueIdNumber;
String title;
List authors;
BookType bookType;
}
class BookItem {
BookInfo bookInfo;
String barcode;
Date publicationDate;
Rack rackLocation;
BookStatus bookStatus;
BookFormat bookFormat;
Date issueDate;
}
My guess would be is-a vs has-a relationship. BookItem is a Book. Here, the subclass is a proper subtype of the parent class. And even in the requirements, it says that these BookItems are copies of a Book.
I also think that a composition would be better idea. We have hunders of bookItems, all of which belong to same bookInfo. It does not make sense to duplicate the information in each and every bookItem class object.
Very helpful. Would be great if you could also add db design for this. Should we design db thinking of classes or not? I always had this doubt!
Thanks for the suggestion will surely do the same!
It's awasome the way you make it simple..now we can call it "jolbhaat"...aaro LLD videos chai bhai...
Great work Soumyajit, you're awesome!!! Just a thought though, we could have overloaded the getBook function in the Search class to take in 4 different parameters shown here rather than having 4 different functions. Lemme know what you think about this. Thanks & best wishes to you!! :)
Nice approach!
Great Job Soumyajit Bhattacharyay !!!
Thanks for the feedback!
Brother you make the most fires oop video, I love it
It would be very helpful if you could share the requirement and actors doc link as well.
Hi Soumya, one thing I wanted to highlight is that in the real interview we would need to run this and show some data. How would we write the driver code in best possible way? In actual interview even if your design is not that great but your code is working with data and all the features is more important. Becoz then we also have to provide the implementation for all the interfaces we defined.
That is not true at all
It depends on the interviewer and what they want to see. In one of my interviews I was asked to write the entire implementation.
In some I was asked to write just the implementation of one or two features.
And in most, I was simply asked to write class design, db design, api contracts.
@@SoumyajitBhattacharyay Yeah agreed.. Many won't ask but many are there who ask. But I just gave it as a feedback.. Becoz I wanted your videos to the one stop solution for LLD. Anyways Np.
Great learning bro!! Haven't you missed notification part?
Great video! One question - Could the Search and BookIssueService be directly added to SystemUser class instead of adding both of them to its child classes i.e. Member and Librarian?
it can be, but then it will voilate Dependency Inversion principle (SOLID).
@@naveengarg7435 how exactly will it violate Dependency Inversion principle, could you please explain ? We will still be relying on interfaces for Search and BookIssueService functionality.
can you do a video on Shipment tracking service and car rental service as well ?
I believe the book Isuse service should not contain methods for issuing and reserving books. These methods belong to Lending class and Book reservation class. The book issue service is just a wrapper because we don't want to replicate the code to both member and librarian. But, this does not make the bookIssueService the owner of these methods. The owner still remains the lending class and reservation class. Now the book issue service may contain object of Lender and reservation which will call the lending and reservation methods or we may completely remove the book issue service and directly put these objects inside the member and librarian too make use of it. But, just because we want to remove code duplicacy, I believe it is wrong to change the ownership of method from lender and book reservation, assign it to a completely new class which is a book issue service.
In LLD interviews, is the expectation to write the entire code with logic? Or define the basic structure with the classes and their attributes and methods?
It was a great video, learnt a lot .Only have one question ,in an Interview whether the requirements will be given to us or we have to ask the interviewer about our queries regarding the requirements or we just have to assume the requirements? Thanks for answering in advance!
Short and Crisp. Thanks, Soumyajit. Do you have resources on HLD as well?
Very Good and valuable content to learn and implement things....please do one video on multithreading or atleast add to the to-do list. Bro
Noted bro. Will add it in my to do list.
I think you missed out Actor: server and notification action.
Can you please explain why or why not we can put Search and BookIssueService in the SystemUser class ?
Great work Soumyajit really helps. Had one question
Why do we need to store info about BookFormat?
What about the methods of each class? What if the interviewers wants us to also implement relevant methods for the said classes, then how shall we practise the same?
extremely pyari explaination :)
Thanks 😛
I have a small doubt here,
Why cannot we define the search and book issue service functions inside the Memeber class, since it will already be inherited by the User and Librarian class?
This would also help us override the search method for eg. in case we don't want to show lost books to customer but librarian can still see it.
Can we override the Search class methods from the Customer class in java ?
I believe library should have racks, and racks should have books. Book(Item) shouldn't contain rack details.
Hi this was great video on LLD. Can search and bookIssueService class be made singleton or static ?
Yes they can be made singleton in nature. Infact most of the service classes are by default singleton classes
@@SoumyajitBhattacharyay Thanks for your response
Hey!! Thanks for these videos.
In the video, FineService was defined but not in Java Code provided by you. You can please that.
i guess writing algorithms and implementing data structures is not a part of LLD? i thought i would see i a complete working code, implementing search through binary search,storing in heap , and other implementations . rest the video was nice and contained all classes
Why the API's aren't implemented ? In the real interview we are expected to write up some of the methods implementation.
Thanks for the video.amazing it is! Everything was decoupled so nicely. I want to be part of the mock interview series.What needs to be done for that?
Thanks for the feedback.
Sure, can you please connect with me over instagram and we can discusbthe details of the mock interview?
Thank you so much. Excellent video to learn LLD.
One doubt though. We are not storing BookIssueDetails anywhere. Does this mean we are storing BookIssuedetails in DB ? So if I have to search for the books issued to a user, how can I know that?
I think that there should be 1 table in the DB(relational) that contains issued books data like IssueId, borrowerId, dateTimeOfIssue, bookItemId, etc. So if you need books issued to a particular member, just query this table passing his ID. Hope I understood your ques right.
Hello, Thanks a lot for the video, its one of the best for explaining OO design paradigms. I find it a bit hard to gather how we are taking care of the fines though. Should the BookIssueService not have a list of BookLendings, so it can track all reservations/issues for one account?
I am new here. Dont we have to write implementation of functions in our low level design during interviews?
If we search on the basis of author then we'll get list of books instead of bookItems hence we wont be able to issue books based on the list of books.
can we use prototype design pattern in BookItem class ? so that every time when new copy of book is added in the inventory we only have to change few fields and persist data. Any views on this?
It seems that your solution doesn't take account list books which a systemUser currently has . Also which book is issued to which user is also missing.
Great and Awesome stuff bro. If interviewer asked for the design patterns we used?
Why we need SystemUser & Account as seperate classes..both can be merged into 1 class...right?.. as we will not do code duplication also & both classes has relevant data..
in these case study where can we use abstract class as i have difficulty using abstract class in real life example.
Great video 👍. When will next video come?
Thanks for the feedback. The next low level design video will come later this week! 🙂
@@SoumyajitBhattacharyay please add extension/modification in feature like ask in interview.
Yes, it is a good suggestion. I have added the same in my low level design book my show video.
ruclips.net/video/7LaKmNfMCAo/видео.html
Hello, the code seems overwhelming to me ,a fresher. Please advice me on how to proceed with lld. I find it hard to put the concepts to code.
why we need library class? Also should nt the "barcode" be the input to the APIs rather than BookItem
Thanks a alot
Can we make the account class as abstract class and add resetPassword method to it?
No it cant be anstract as first time we will have to intialize the account object for a particular use. Reset password can be added.
library class should be singleton
Book item list is defined in Library class. but for the search class to search for a book with a particular Author's name it needs a list of book items..can someone please tell me how do we pass this list?
"Person" and "SystemUser" should be declared as abstract classes as their instantiation has no significance.
Copy of grokkling system design
Great Stuff !!
Glad you enjoyed it
hey what if I want to find that to whom this particular book is assigned, how can I find that? by keeping customer id in book item?
probably - Bookissueservice has getReservationDetail api
BookItem HAS a book and IS not a book itself. I belive book should be an attribute of the BookItem class.
Also Author is not an Actor on the system. It makes sense to have another base class like Actor extends Person.
Hi generally as a rule of thunb the is a and has a relationships are applied over real world objects. hence Book item is considered as the real world representation of the book here.
Share requirements too
It is shred in the previous video already. 😊
@@SoumyajitBhattacharyay requirements which you are reading and making all usecases... It's not there
Isnt it in the part 1 video. This is the part 2 video of it. 😊 Or are you requesting the file. In that case it's not there. Sure will add it.
Could you do a LLD video on how to design Linux Find file Command. Also I think the parameters should be private in order to show Encapsulation.
Thanks for the feedback. Will definitely shoot the same!
Rack class should contain BookItem , but here BookItem is containing RackLocation
why is Search not called SearchService?
Yes search can be called a search service here. Because it will be implementing ther service aspect of search.
Hi,
1. How will you support edit,delete,update book item operations?Dont you think we use use Hasmap instead of List in library class to support these operations in constant time as edit,delete,add will result in updating data in Library class List.
2. How will this information be passed to search service so that it can update its data?
3.Why do we need to put searchService and BookIssueService objects in Member and librarian Class?Book issue service will take user and book while issuing a book,but it will not be called from Member class,right?We will not say Member.issueService.issueBook,it does not make sense.I mean we cannot show that interaction will classCode only.
Let me know your thoughts?
1) How ever you may go ahead and use a hashmap, But be mindful as it is not required here. The edit, delete and update operations will not be done in memory. These operations will be done in persistent storage and hence a hashmap not required.
2) For performing basic CRUD operations we can have specific APIs that do the same, But with the problem statement in mind need to define the basic CRUD APIs.
3) The BookIssue service will be called from the member class. As per the requirements, the member should be able to issue books on their own. If you go and watch the use case diagram it will be come more clear as to which class should have access to which services. Hence it should be a part of the Member class as now, it will give the Member object (AKA the person who want to borrow the book) permissions to issue the book using the system rather than having to do that through the librarian. Apart from the Member the librarian should also have the scope to access the BookIssueService and the SearchService.
Member should be given exact permissions to actually perform searches and issue book by self checkout kiosks. That is the whole point of the Library management system.You can go through my previous video to understand the interaction between the different actors to get an understanding of the scope of the system.
Before writing the code, we should analyse all the work flows properly and then only start with their implementation.
@@SoumyajitBhattacharyay Thanks for quick reply.I am fine with point 1 and 2 raised above.But i still have doubts about 3rd point.So do we need to add methods of issue book and all in Member class also?Which will internally call Book reservation issue?Dont you think that it is not responsibility of user class to manage book issue/return and renew. Shouldn't this responsibility be separated from member class?
Did anyone notice the time on his Laptop?
Hahah. That is the time that I get to shoot the videos. 😊
@@SoumyajitBhattacharyay Kudos to your hardwork Bhaiya. Your videos are really helpful. I'll crack Product based some day and tag you on LinkedIn 😁
Heheh. Thank you 💗. Yaar bilkul.
If someone give these requirements written in full sentences, i believe anyone can come up with their own LLD. The difficult part is understanding the ask and gather requirements.
Not true for the first part. True for the second part.
I have seen way too many folks not come up with the design of systems even after getting the requirements.
But true, coming up with the requirements that will happen over time when you are exposes to such scenarios at work.
At work we constantly get such scenarios where we have to create the entire business requirement document also known as the BRD. It is something that cannot be tought and have to come with experience.
bhai pehele class diagram toh bataao, seedha code kar diye ho