03 Laboratory Exercise 1 Application Development and Emerging Technologies SOLID Principles Analysis Name: Emman Gregory T. Martin Section: BT3103 Teacher: Sir Wendell
Single Responsibility Principle (Before) Violation : The Book class has multiple responsibilities (e.g., storing data and saving to database). This violates SRP because one class should only have one reason to change.
Single Responsibility Principle (After) Solution : Separated responsibilities into Book (data) and BookRepository (persistence). Now each class has a single responsibility, making maintenance easier.
Open-Closed Principle (Before) Violation : The Book class must be modified whenever a new discount type is added. This breaks OCP because existing classes should not need modification.
Open-Closed Principle (After) Solution : Created an abstract DiscountStrategy with subclasses for each discount. Book depends on the abstraction. New discounts can be added without modifying existing code.
Liskov Substitution Principle (Before) V iolation : DigitalBookOrder cannot correctly substitute BookOrder because shipping fee causes errors. This violates LSP since subclasses must work wherever the base class is expected.
Liskov Substitution Principle (After) Solution : Split orders into PhysicalBookOrder and DigitalBookOrder . Both inherit BookOrder and behave consistently, preserving substitutability.
Interface Segregation Principle (After) Solution : Split the IBookAction interface into PrintedBookUI and AudioBookUI . Each user interface only implements the actions it actually uses. This avoids forcing classes to depend on unused methods.
Dependency Inversion Principle (Before) Violation : BookManagement directly depends on concrete low-level classes ( UpdateCookBookShelf , UpdateHistoryBookShelf ). This breaks DIP since high-level classes should not depend on low-level details.
Dependency Inversion Principle (After) Solution : Introduced IBook abstraction. Both UpdateCookBookShelf and UpdateHistoryBookShelf implement it. BookManagement now depends on the IBook interface, making the system flexible and extensible.