Bird
0
0
LLDsystem_design~20 mins

Class design (Book, Member, Librarian, Loan) in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Library System Design Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Identify the correct relationship between classes
In a library system, which relationship best describes how the Loan class relates to the Book and Member classes?
ALoan is unrelated to Book and Member and operates independently.
BLoan has a composition relationship with Book and Member, meaning Loan owns them and controls their lifecycle.
CLoan inherits from both Book and Member classes to combine their properties.
DLoan has an association relationship with Book and Member, meaning Loan references them but does not own them.
Attempts:
2 left
💡 Hint
Think about whether Loan should control the existence of Book or Member objects.
Architecture
intermediate
1:30remaining
Choose the best class to handle book availability status
In the library system, which class should be responsible for tracking whether a book is currently available for loan?
AThe Loan class should track availability by checking if a book is loaned out.
BThe Member class should track availability of books they want to borrow.
CThe Book class should track its availability status directly.
DThe Librarian class should maintain a separate list of available books.
Attempts:
2 left
💡 Hint
Consider which class naturally owns the state of the book itself.
scaling
advanced
2:00remaining
Design consideration for handling thousands of loans
If the library system must handle thousands of simultaneous loans, which design choice improves scalability and performance?
AUse a database to store Loan records and query only active loans when needed.
BStore all Loan objects in memory within the Librarian class for quick access.
CCreate a new Loan object for each request and keep them permanently in a list inside Member objects.
DSerialize all Loan objects to a file after each loan creation.
Attempts:
2 left
💡 Hint
Think about memory usage and data retrieval efficiency for large data.
tradeoff
advanced
1:30remaining
Tradeoff in making Member class responsible for loan history
What is a potential downside of storing all loan history inside each Member object?
AIt can cause high memory usage if members have many loans.
BIt simplifies querying loan history across all members.
CIt improves performance by avoiding database queries.
DIt prevents members from borrowing multiple books.
Attempts:
2 left
💡 Hint
Consider what happens when a member has a very long loan history.
component
expert
2:00remaining
Identify the correct sequence of actions when a book is loaned
What is the correct order of actions when a member borrows a book from the library?
A3, 1, 2, 4
B1, 2, 3, 4
C2, 1, 3, 4
D1, 3, 2, 4
Attempts:
2 left
💡 Hint
Think about the logical order to ensure the book can be loaned before creating records.