Lab Manual 05 - 10-11-2022
Lab Manual 05 - 10-11-2022
Lab 05
Student Information
Student Name
Student ID
Date
Assessment
Marks Obtained
Remarks
Signature
Software Design Principle (SOLID)
Several principles have been identified throughout the literature that help in making
component-level design decisions, including (SOLID). These design principles
intended to make object-oriented designs more understandable, flexible, and
maintainable. The principles are a subset of many principles promoted by American
software engineer and instructor Robert C. Martin [1] also called "Uncle Bob".
1. Single Responsibility Principle
2. The open–closed principle (OCP)
3. The Liskov substitution principle (LSP)
4. The interface segregation principle (ISP)
5. Dependency Inversion Principle
Consider any game application that do gaming activities as well as to track the scores,
so the Game class kept the responsibility to keep game playing activities, and the Scorer
class got the responsibility to calculate the score and keep all score as stats section.
Rectification : To make the Game class conforms to the single responsibility principle, you’ll need
to create another class that is in charge of storing game scores in database
[1] Martin, Robert C. (2000). "Design Principles and Design Patterns" (PDF). Retrieved 2022-11-10
http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf
2. The open–closed principle (OCP)
The open-closed principle states that a class, method, and function should be open for
extension but closed for modification.
Rectification: Now Employee is an abstract class and it has an abstract method called
work. All subclasses of this class have to implement a work function. Developer calls its
develop method and Tester calls its test method. In the company, all we had to do is calling
the work() method of the given employee. If I need to add a new Employee like Maintenance
Engineer, all you need to do is implement the work() method
Exercise 3: Use the Liskov Substitute principle and implement it with your own scenario.
Exercise 4: Use the Interface Sagregation principle and implement it with the given scenario
(Web Resource).
Exercise 5: Use the Dependency Inversion principle and implement it with given scenario
(Web Resource).