Lab#SE03-3: Library/Book, Expand Model
Java SE Lab 03 part 3
📘 Linux Lab#SE03-3: LibraryProject Expand Model
In LibraryProject
, the User
and Staff
classes could have different operations
that they are authorize/able to perform.
The User
class could have the following operations:
- Search for books
- Borrow a book
- Return a book
- Check the status of borrowed books
- Update personal information
The Staff
class could have the following operations:
- Add a new book
- Remove a book
- Update the book details
- Register a new user
- Remove a user
- Update the user details
- Generate reports on library operations
To implement
these operations, we could define three separate interfaces
:
- UserOperations
- StaffOperations
- GeneralOpeations
1 Interfaces
The three interfaces GeneralOperations
, UserOperations
, and StaffOperations
provide a clear separation of concerns and responsibilities within the library management system.
In a library project, having separate interfaces for different types of operations will help to keep the code organized and maintainable.
GeneralOperations
interface
provides methods that are commonly used by both users and staff, such as searching for books and creating an account.
UserOperations
interface
includes methods that are specific to users, such as updating personal information, borrowing and returning books, and checking their borrowed books.
StaffOperations
interface
includes methods that are specific to staff members, such as adding, removing, and updating book details, as well as registering and updating user details and generating reports.
By separating these different functionalities into interfaces, it becomes easier to implement and maintain the system.
For example, a developer could create different classes that implement the UserOperations interface, such as Student or Faculty, which will all have their own implementation of the methods defined in the interface.
2 Abstract class
Finally, the LibraryMember
abstract class is a parent class for users and staff members, which includes common fields such as id, address, and phoneNumber.
By defining these fields in an abstract
class, it allows for different types of users and staff members to inherit them and avoid duplication of code.
public interface GeneralOperations {
public void searchBooks(String query);
public void createAccount();
}
public interface UserOperations {
public void updatePersonalInformation();
public void borrowBook(Book booLab#SE00-3: Library Modelk);
public void returnBook(Book book);
public void checkBorrowedBooks();
}
public interface StaffOperations {
public void addBook(Book book);
public void removeBook(Book book);
public void updateBookDetails(Book book);
public void registerUser(User user);
public void removeUser(User user);
public void updateUserDetails(User user);
public void generateReports();
}
Using interfaces
and abstract
classes in this way can make the code more modular and easier to maintain, as it allows for greater flexibility and extensibility.
3 UML
3.1 Previous UML proposals
The two UML diagrams describe the core features of a libraryProject, specifically the use cases for borrowing and issuing books, as well as the roles and responsibilities of users and librarians/staff members.
The first diagram,
Core features: borrow and issue
, depicts the interaction between the user and the system, as well as the system and the librarian:
The second diagram,
Core features: user and librarian (staff)
, expands on the roles and responsibilities of users and librarians/staff members.
3.2 Solving discussion: actors UML
THE UML diagram describes our LibraryProject that includes three interfaces: GeneralOperations, UserOperations, and StaffOperations.
GeneralOperations
provides two methods, createAccount() and searchBooks(String query), that allow users to create an account and search for books.UserOperations
provides four methods that allow users to update their personal information, borrow and return books, and check the books they have borrowed.StaffOperations
provides several methods that allow staff to add, remove, and update books, as well as register, remove, and update user details and generate reports.
3.3 Solving discussion: actors UML & core-model
The diagram also includes four classes: User
, Author
, Staff
, and Book
.
User represents a library member with a library card number and a list of borrowed books. Author represents the author of a book, with details including their name, nationality, and birth and death dates.
Staff represents a staff member with a staff ID, position, and lists of registered users and library books. Book represents a book with details including its title, author, publisher, publication year, ISBN, and status.