This is a student project that explores core object-oriented design patterns through the context of a simple library management system. The goal was not to create a polished application, but to demonstrate the application of patterns like Decorator, Factory, Strategy, and Observer in a realistic but minimal use case.
Originally implemented as a Windows Forms app, it has been refactored to a console application to better focus on showcasing the design logic.
- Factory Pattern: Used to instantiate different types of books (
NovelFactory
,MagazineFactory
) based on context. - Decorator Pattern: Adds dynamic functionality to books, such as:
LateFeeDecorator
: Applies a late fee when a book is returned.BorrowingPeriodExtensionDecorator
: Extends the loan period.
- Strategy Pattern: Controls the loan duration depending on the borrower:
StudentLoanStrategy
LibraryStaffLoanStrategy
- Observer Pattern: Notifies library users when books become available.
- Register students and library staff as observers.
- Create books and add them to inventory.
- Borrow and return books with different loan strategies.
- Apply decorators to alter book behavior at runtime.
- Get notified when a borrowed book is returned.
Clone the repository:
git clone https://github.com/yourusername/DesignPatterns.git
- Open the
DesignPatterns.sln
file in Visual Studio 2022 or later. - Ensure the project targets .NET 6.