Design a Library Management System
Design a Library Management System
System
A Library Management System is a software built to handle the
primary housekeeping functions of a library. Libraries rely on
library management systems to manage asset collections as well as
relationships with their members. Library management systems
help libraries keep track of the books and their checkouts, as well
as members’ subscriptions and profiles.
System Requirements
💡 Always clarify requirements at the beginning of the
interview. Be sure to ask questions to find the exact scope of
the system that the interviewer has in mind.
10. Each book and member card will have a unique barcode.
The system will be able to read barcodes from books and
members’ library cards.
Class diagram
Here are the main classes of our Library Management System:
Book: The basic building block of the system. Every book will
have ISBN, Title, Subject, Publishers, etc.
BookItem: Any book can have multiple copies, each copy will
be considered a book item in our system. Each book item will
have a unique barcode.
Activity diagrams
Check-out a book: Any library member or librarian can perform
this activity. Here are the set of steps to check-out a book:
Code
Here is the code for the use cases mentioned above: 1) Check-out a
book, 2) Return a book, and 3) Renew a book.
Note: This code only focuses on the design part of the use cases.
Since you are not required to write a fully executable code in an
interview, you can assume parts of the code to interact with the
database, payment system, etc.
Enums and Constants: Here are the required enums, data types,
and constants:
// For simplicity, we are not defining getter and setter functions. The reader can
// assume that all class attributes are private and accessed through their respective
// public getter methods and modified only through their public methods function.
if (!bookItem.checkout(this.getId())) {
return false;
}
this.incrementTotalBooksCheckedout();
return true;
}
bookItem.updateDueDate(LocalDate.now().plusDays(Constants.MAX_LENDING_DAYS)
);
return true;
}
}