We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5
NAME : Faizan e ali
Reg number : fa23-bce-111
Course : software engineering
Report on Library Management System Using MVC Architecture
Introduction The Library Management System (LMS) is designed to automate and manage library operations, providing users with the ability to manage books efficiently. In this report, we will discuss the architecture and design of a Library Management System implemented using the Model- View-Controller (MVC) pattern in Java. This approach ensures separation of concerns, making the system modular, scalable, and easier to maintain. The primary functions of the system include adding, viewing, and removing books from the library. Objectives To design a Library Management System using the MVC architecture in Java. To allow users to manage books (add, remove, view) through a simple command-line interface. To ensure clean separation of data handling (Model), user interface (View), and business logic (Controller). MVC Architecture The Model-View-Controller (MVC) design pattern divides the application into three interconnected components: 1. Model: Represents the data and the business logic. It manages the state of the application and contains the core functionality. 2. View: Responsible for displaying data to the user. It retrieves data from the model and displays it in an appropriate format. 3. Controller: Acts as an intermediary between the Model and View. It processes user input, updates the model, and provides feedback to the view. System Design 1. Model: Book and BookDAO The Model layer consists of two components: Book and BookDAO. Book Class: Represents the data structure for a book in the library. Each Book has attributes such as: o id: Unique identifier for the book. o title: The title of the book. o author: The author of the book. o year: The year the book was published. The class provides getter and setter methods for each of these attributes and a toString method to format the output when displaying book details. BookDAO Class: Manages the data of books stored in a collection (ArrayList in this case). It provides methods to: o addBook(): Adds a book to the collection. o getAllBooks(): Retrieves all books in the collection. o getBookById(): Searches for a book by its ID. o removeBook(): Removes a book by its ID. 2. View: LibraryView The View layer is responsible for displaying information to the user. The LibraryView class handles all user output: displayBooks(): Displays all books in the library. displayBook(): Displays details of a single book. displayMessage(): Displays a general message to the user (e.g., success or error messages). The View does not directly interact with the data. It only displays the data provided by the Controller. 3. Controller: LibraryController The Controller layer is where the business logic resides. It acts as an intermediary between the Model and the View. The LibraryController class provides methods to: addBook(): Calls the BookDAO.addBook() method to add a new book. getAllBooks(): Retrieves all books from the BookDAO and passes them to the view. getBookById(): Searches for a book by its ID and displays it using the view. removeBook(): Removes a book by its ID from the collection and informs the user of the result. The controller contains the application's business logic, such as determining which method to call and managing the flow of data between the model and view. 4. Main: LibraryManagementSystem The Main class is responsible for providing the user interface, specifically a simple command-line interface (CLI). It prompts the user to choose different actions, such as adding a book, viewing books, and removing books. Based on user input, the appropriate methods from the LibraryController are called. The view displays the result of each operation. Functionality 1. Add Book: o The user inputs the details of the book (ID, title, author, year), which the system stores in the collection. 2. View All Books: o The system retrieves and displays all books currently stored in the library. 3. View Book by ID: o The user can search for a book by its unique ID. If the book exists, its details are displayed; otherwise, an error message is shown. 4. Remove Book: o The system allows users to remove a book by its ID. If the book exists, it is removed from the collection, and the user is notified. If the book does not exist, an error message is shown. Conclusion The Library Management System implemented using the MVC pattern is a simple yet effective way to manage a library's collection of books. The system allows the user to add, view, and remove books using a command-line interface. Key benefits of this approach: Separation of Concerns: Each component (Model, View, Controller) has a distinct responsibility. The model handles the data, the view handles the presentation, and the controller coordinates between the two. Scalability: The system is easily extendable. New features such as searching books by title or author can be added without affecting the existing code. Maintainability: By separating the business logic from the user interface, the system is easier to maintain and modify.