Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Riphah International University

Islamabad I-14 main campus

Course code CS2104 Course Title Software Design & Architecture Lab

Lab 03 Objective SOLID (First three principles)

 Instructions:
 You must use meaningful names of classes, attributes, methods, etc.
 You will not add your name, identity, lab or task number or anything else inside
the document.
 Write your file name as “ SAP-ID.pdf ” for example “ 22345.pdf ”.
 In case of handwritten task, your presentation/handwriting must be representable.

 Warning:
 In case of cheating, all members whose files are caught gain zero marks without
any justification.

 Marks distributions:

No Requirement Marks
1 Meaningful names 2

2 Problem identified 3

3 Provided solution 5
 Demonstration:
 Single Responsibility Principle
“A class should have one, and only one, responsibility”

This does not mean that one class will have only one method, there can be
multiple methods but of same type as the type of class.
 Open-Close Principle
“Class should be open for extension, but closed for modification”

This requires if you want to add some extra functionality into your program,
you should not add new method. You must create a new class and extend that
class from the previous one.
 Liskov Substitution Principle
“Objects in a program should be replaceable with instances of
their subtypes without disrupting the behavior of our program”

This principle requires that if you want to add some new class which extends any
class, then the new class must be completely interchange with its parent class.
 Tasks

o Evaluation task

 Identify the change and apply change according to Single Responsibility


Principle

 Apply Open-Close Principle


Understand the new adding functionalities and apply according to OCP.

Adding GST as new functionality Adding Apply_cover & cover_style_id as


new functionality.
 Apply Liskove Substitution Principle
Understand the new adding functionalities and apply according to OCP.

Add TelePhone & SmartPhone classes Add AudioBook, PrintedBook, EBook classes

You might also like