This project demonstrates a functional Library Management System written in Java with intentionally implemented code smells for educational purposes.
Assignment 2/
├── src/
│ ├── main/java/
│ │ ├── Book.java # Book entity class
│ │ ├── Member.java # Member entity class
│ │ ├── LibrarySystem.java # Main system class (God Class)
│ │ ├── MemberValidator.java # Utility class with Feature Envy
│ │ ├── BookUtilities.java # Utility class with duplicated code
│ │ └── Main.java # Main class with demo and tests
│ └── test/java/
│ └── LibrarySystemTest.java # Comprehensive unit tests
└── docs/
└── smells.md # Documentation of code smells
- Add and manage books in the library
- Add and manage library members
- Borrow and return books with due date tracking
- Search books by title, author, or ISBN
- Member validation and risk assessment
- Fine calculation for overdue books
- Transaction history tracking
- Comprehensive unit testing
- Long Method - borrowBook() method in LibrarySystem.java
- God Class (Blob) - LibrarySystem class handles too many responsibilities
- Duplicated Code - Validation logic repeated in multiple places
- Large Parameter List - validateMemberForBorrowing() method
- Magic Numbers - Hardcoded values throughout the codebase
- Feature Envy - Utility classes overly interested in other classes' data
cd "src/main/java"
javac *.javajava MainThe program will:
- Demonstrate library functionality
- Show borrowing and returning processes
- Display search results
- Run 8 comprehensive unit tests
- Show 100% test success rate
- Total Lines of Code: ~679 lines (including Main.java with tests)
- Core System Code: ~526 lines (excluding Main.java)
- Test Coverage: 8 unit tests covering all major functionality
- Success Rate: 100% (all tests pass despite code smells)
This project demonstrates that:
- Code can be functional while still having poor design
- Code smells make maintenance and extension difficult
- Proper refactoring would improve code quality significantly
- Unit tests can validate functionality even with smelly code
See docs/smells.md for detailed documentation of each code smell with file locations and justifications.