SlideShare a Scribd company logo
SOFTWARE DESIGN PRINCIPLES
CRISTAL NGO
ICT2106 – SOFTWARE DESIGN – WEEK 2
PREVIOUSLY IN ICT2106
–What is software design?
–Importance of software design
–Software design process
–What is a good design/software/process
2
READING
– Software engineering design, Carlos Otero,
Chapter 1 (Software Design Fundamentals)
4
GENERAL DESIGN PRINCIPLES
1. Modularization
2. Abstraction
3. Encapsulation
4. Coupling
5. Cohesion
6. Separation of interface and implementation
7. Sufficiency
8. Completeness
5
PRINCIPLE #1: MODULARIZATION
Modularization is the process of continuous decomposition
of the software system until fine-grained components are
created.
When you modularize a design, you are also modularizing the
requirements, programming and test cases. 6
PRINCIPLE #2: ABSTRACTION
Abstraction is “a view of an object
that focuses on the information
relevant to a particular purpose and
ignores the remainder of the
information”
7
ABSTRACTION
Abstraction can be employed to extract essential
characteristics of:
Procedures or
behavior
Data
8
PROCEDURAL ABSTRACTION
SEND(client, server, message)
1. Client retrieves the serverʼs information,
2. opens a TCP/IP connection,
3. sends the message, waits for response, and
4. closes the connection
Simplifies reasoning about behavioural
operations containing a sequence of
steps
9
DATA ABSTRACTION
MESSAGE is an example of the data abstraction; the details of a
MESSAGE can be deferred to later stages of the design phase.
SEND(client, server, message)
Simplifies reasoning
about structural
composition of data
objects
10
PRINCIPLE #3: ENCAPSULATION
Encapsulation deals with providing access to services of
abstracted entities by exposing only the information that is
essential to carry out such services while hiding details of how the
services are carried out.
Information hiding: Internal details (state,
structure, behavior) become the objectʼs
secret
11
ENCAPSULATION & INFORMATION HIDING
– One can think of information hiding as the
principle and encapsulation as the technique
– Encapsulation is the public interface that
defines how an object can be used, and how
its data is derived.
– Information Hiding prevents an external object
from using the derived data altogether
13
ENCAPSULATION & INFORMATION HIDING
class Automobile extends Vehicle {
public final static int EMPTY = 0;
public final static int FULL = 1;
public int tank = EMPTY;
}
Neither Encapsulation nor Information Hiding
14
ENCAPSULATION & INFORMATION HIDING
class Automobile extends Vehicle {
public final static int EMPTY = 0;
public final static int FULL = 1;
private int tank = EMPTY;
public int getTankStatus() {
return this.tank;
}
public void setTankStatus( int status ){
this.tank = status;
}
}
The status of the
tank is now
encapsulated, but
NOT HIDDEN from the
rest of the system.
15
class Automobile extends Vehicle {
private final static int EMPTY = 0;
private final static int FULL = 1;
private int tank = EMPTY;
private int tank() {…}
private void tank( int status ) {…}
public void fillUp() {
tank( FULL );
}
public void depleteOzone() throws GasExhaustedException {
if( tank() == FULL ) {
tank( EMPTY );
}
else {
throw new GasExhaustedException();
}
}
}
A simple interface fully
Encapsulates and Hides
Information: fillUp() and
depleteOzone().
No other object in the
system can use, or know
the state of, the gas
tank.
16
MODULARIZATION, ABSTRACTION & ENCAPSULATION
Focus on essential
characteristics of entities
Enforce that we only expose
essential information
17
PRINCIPLE #4: COUPLING
The higher
the coupling
The higher
the
dependency
Refers to the manner and degree of
interdependence between software modules.
Measurement of dependency between units.
18
COUPLING:
DEGREE OF DEPENDENCE AMONG COMPONENTS
No dependencies Loosely coupled-
some dependencies
Highly coupled-
many
dependencies
High coupling makes modifying parts of the system difficult, e.g., modifying a
component affects all the components to which the component is connected
19
Content
Common
Control
Stamp
Data
TIGHT COUPLING LOOSE COUPLING
More interdependency
More coordination
More information flow
Less interdependency
Less coordination
Less information flow
21
CONTENT COUPLING
Definition: A module directly references the
content of another module
1. Module p modifies a statement of module q
2. Module p refers to local data of module q (in terms of a
numerical displacement)
3. Module p branches to a local label of module q
22
COMMON COUPLING
– Using global variables (i.e., global coupling)
– All modules have read/write access to a global
data block
– Modules exchange data using the global data
block (instead of arguments)
Single module with write access where all other modules have
read access is not common coupling 23
COMMON COUPLING -
EXAMPLE
while( global_variable > 0 ){ 
switch( global_variable ){ 
case 1: function_a(); break;
case 2: function_b(); break;
...
case n: ...
}
global_variable++;
}
If function_a(),
function_b(), etc
can modify the
value of global
variable, then it
can be
extremely
difficult to
track the
execution of
this loop
24
STAMP COUPING
Occurs when too much information is passed to
a function.
typedef struct rectangle
{
int length;
int width; 
int area;
int perimeter;
int color;
double diagonal;
char symbol;
} RECTANGLE;
RECTANGLE CalcArea (RECTANGLE r)
{
r.area = r.width * r.length;
return r;
}
We are passing an entire RECTANGLE to this function,
even though the function really does not need to see or
modify all of the members.
25
DATA COUPLING
Process
Results
Calculate
Grade
mark grade
Two modules are data coupled if they
communicate by passing parameters
and no extra data are passed.
Data coupling exhibits the properties
that all parameters to a module are
either simple data types, or in the case
of a record being passed as a parameter, all
data members of that record are
used/required by the module.
26
DATA COUPLING – MORE EXAMPLE
typedef struct rectangle
{
int length;
int width; 
int area;
int perimeter;
int color;
double diagonal;
char symbol;
} RECTANGLE;
int CalcArea(int width, int length)
{
int area;
area = width * length;
return area;
}
This is a better way to write the previous program. Here
we will be passing and returning only primitive data types.
They are all that is really needed by the functions and
now the functions are more general, too.
27
PRINCIPLE #5: COHESION
– The manner and degree to which the tasks
performed by a single software module are
related to one another.
– Measures how well design units are put
together for achieving a particular tasks.
28
COUPLING AND COHESION
–Cohesion is defined as the degree to which all elements
of a module, class, or component work together as a
functional unit. High cohesion is good, and low cohesion is
bad.
–Coupling is defined as the degree of interdependence
between two or more classes, modules, or
components. Tight coupling is bad, and loose coupling is
good.
29
LOOSE COUPLING - HIGH COHESION
30
In essence, high cohesion means keeping parts of a code base that are
related to each other in a single place. Low coupling, at the same
time, is about separating unrelated parts of the code base as much
as possible.
DEGREE OF
COHESION
High Cohesion
Low Cohesion
31
COINCIDENTAL COHESION
This is the weakest form of cohesion. Its
element have no meaningful relationship.
32
PROCEDURAL COHESION
– A module has procedural cohesion if all the
operations it performs are related to a sequence of
steps performed in the program.
– For example, if one of the sequence of operations in
the program was “read input from the keyboard,
validate it, and store the answers in global variables”,
that would be procedural cohesion.
33
operationA(){
readData(data,filename1);
processAData(data);
storeData(data,filename2);
}
readData(data,filename){ 
f = openfile(filename);
readrecords(f, data);
closefile(f);
}
storeData(data,filename)
{...}
processAData(data)
{...}
Module A
PROCEDURAL
COHESION EXAMPLE
34
INFORMATIONAL COHESION
– Information cohesion describe a module performing
a number of operations, each with a unique entry
point and independent code, and all operations are
performed on the same data.
– In information cohesion, each function in a module
must perform exactly one action
35
INFORMATIONAL COHESION
The Object-oriented approach naturally produce
designs with informational cohesion
– Each object in general has its own source code/file
– Each object operates on its own data which are
defined within the object.
– Each member function of the object should perform
one unique action/operation/function.
36
INFORMATIONAL COHESION EXAMPLE
class Airplane{
private double speed, altitude;
public void takeoff() {…}
public void fly() {…}
public void land() {…}
}
class Airplane
37
TYPES OF CODE
FROM A COHESION
AND COUPLING
PERSPECTIVE
38
http://enterprisecraftsmanship.co
m/2015/09/02/cohesion-
coupling-difference/
POORLY SELECT BOUNDARIES
as the result of High Coupling Low Cohesion
39
The problem here is that they
are selected improperly and
often do not reflect the actual
semantics of the domain.
DESTRUCTIVE DECOUPLING
as the result of low coupling, low cohesion
40
It sometimes occurs when a
programmer tries to decouple
a code base so much that the
code completely loses its
focus:
SEPARATION OF INTERFACE AND IMPLEMENTATION
This principle involves
defining a component
by specifying a public
interface (known to the
client of the
component) that is
separate from the details
of how the component
is realized.
Interface
Implementation
42
SEPARATION VS. ENCAPSULATION
How is this principle different from Encapsulation?
43
SEPARATION VS. ENCAPSULATION
“During encapsulation, interfaces are created to provide
public access to services provided by the design unit while
hiding unnecessary details, which include implementation.
While encapsulation dictates hiding the details of
implementation, the principle of separation dictates their
separation, so that different implementation of the same
interface can be swapped to provide modified or new
behavior.”
44
PRINCIPLE #7,8:
COMPLETENESS AND
SUFFICIENCY
– Completeness
measures how well
designed units provide
the required services to
achieve the intent (no
less).
– Sufficiency measures
how well the designed
units are at providing
only the services that
are sufficient for
achieving the intent
(no more).
45
Apple has really come up with lots of smart ideas
to improve simple app like photo editing which
reduces the number of clicks required and still get
the work done.
Completenessandsufficiency
46
PRACTICAL DESIGN CONSIDERATIONS
Design for minimizing complexity
Design for change
49
Ad

More Related Content

What's hot (20)

Software testing ppt
Software testing pptSoftware testing ppt
Software testing ppt
Heritage Institute Of Tech,India
 
Software Process Models
Software Process ModelsSoftware Process Models
Software Process Models
Hassan A-j
 
Software design
Software designSoftware design
Software design
Syed Muhammad Hammad-ud-Din
 
SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4  SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4
Mohammad Faizan
 
UML
UMLUML
UML
iQra Rafaqat
 
Defining the Problem - Goals and requirements
Defining the Problem - Goals and requirementsDefining the Problem - Goals and requirements
Defining the Problem - Goals and requirements
Stephennancy
 
Black Box Testing
Black Box TestingBlack Box Testing
Black Box Testing
Testbytes
 
Modules and modularization criteria
Modules and modularization criteriaModules and modularization criteria
Modules and modularization criteria
Umaselvi_R
 
3. ch 2-process model
3. ch 2-process model3. ch 2-process model
3. ch 2-process model
Delowar hossain
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
Sudarsun Santhiappan
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
Haitham El-Ghareeb
 
Software design, software engineering
Software design, software engineeringSoftware design, software engineering
Software design, software engineering
Rupesh Vaishnav
 
Software architecture design ppt
Software architecture design pptSoftware architecture design ppt
Software architecture design ppt
farazimlak
 
Software quality
Software qualitySoftware quality
Software quality
Sara Mehmood
 
Chapter 1 2 - some size factors
Chapter 1   2 - some size factorsChapter 1   2 - some size factors
Chapter 1 2 - some size factors
NancyBeaulah_R
 
Ooad unit – 1 introduction
Ooad unit – 1 introductionOoad unit – 1 introduction
Ooad unit – 1 introduction
Babeetha Muruganantham
 
Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5
koolkampus
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software Engineering
Saqib Raza
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and types
Confiz
 
Integration testing
Integration testingIntegration testing
Integration testing
queen jemila
 
Software Process Models
Software Process ModelsSoftware Process Models
Software Process Models
Hassan A-j
 
SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4  SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4
Mohammad Faizan
 
Defining the Problem - Goals and requirements
Defining the Problem - Goals and requirementsDefining the Problem - Goals and requirements
Defining the Problem - Goals and requirements
Stephennancy
 
Black Box Testing
Black Box TestingBlack Box Testing
Black Box Testing
Testbytes
 
Modules and modularization criteria
Modules and modularization criteriaModules and modularization criteria
Modules and modularization criteria
Umaselvi_R
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
Haitham El-Ghareeb
 
Software design, software engineering
Software design, software engineeringSoftware design, software engineering
Software design, software engineering
Rupesh Vaishnav
 
Software architecture design ppt
Software architecture design pptSoftware architecture design ppt
Software architecture design ppt
farazimlak
 
Chapter 1 2 - some size factors
Chapter 1   2 - some size factorsChapter 1   2 - some size factors
Chapter 1 2 - some size factors
NancyBeaulah_R
 
Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5Software Requirements in Software Engineering SE5
Software Requirements in Software Engineering SE5
koolkampus
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software Engineering
Saqib Raza
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and types
Confiz
 
Integration testing
Integration testingIntegration testing
Integration testing
queen jemila
 

Similar to software design principles (20)

Oracle RI ETL process overview.
Oracle RI ETL process overview.Oracle RI ETL process overview.
Oracle RI ETL process overview.
Puneet Kala
 
DSD
DSDDSD
DSD
VIKASH SAMRAT
 
Chapter 1- IT.pptx
Chapter 1- IT.pptxChapter 1- IT.pptx
Chapter 1- IT.pptx
ssuserb78e291
 
Readme
ReadmeReadme
Readme
rec2006
 
Linux Assignment 3
Linux Assignment 3Linux Assignment 3
Linux Assignment 3
Diane Allen
 
assignment character education assignment
assignment character education assignmentassignment character education assignment
assignment character education assignment
tsegayeblen57
 
UDP Report
UDP ReportUDP Report
UDP Report
James Dianics
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming
Rokonuzzaman Rony
 
Unit-III(Design).pptx
Unit-III(Design).pptxUnit-III(Design).pptx
Unit-III(Design).pptx
Fajar Baskoro
 
Java programming concept
Java programming conceptJava programming concept
Java programming concept
Sanjay Gunjal
 
UNIT-1.pptx python for engineering first year students
UNIT-1.pptx python for engineering first year studentsUNIT-1.pptx python for engineering first year students
UNIT-1.pptx python for engineering first year students
SabarigiriVason
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
Diwakar Pratap Singh 'Deva'
 
Exhibit design and programming skills to build and automate business solution...
Exhibit design and programming skills to build and automate business solution...Exhibit design and programming skills to build and automate business solution...
Exhibit design and programming skills to build and automate business solution...
sramani6
 
Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2
Rajeev Rastogi (KRR)
 
Go Faster With Native Compilation
Go Faster With Native CompilationGo Faster With Native Compilation
Go Faster With Native Compilation
PGConf APAC
 
Algorithm
AlgorithmAlgorithm
Algorithm
Prajakta Bagal
 
Design concepts and principles
Design concepts and principlesDesign concepts and principles
Design concepts and principles
saurabhshertukde
 
Lec1
Lec1Lec1
Lec1
Ibrahim El-Torbany
 
Tasks, functions and User Defined Programss.pptx
Tasks, functions and User Defined Programss.pptxTasks, functions and User Defined Programss.pptx
Tasks, functions and User Defined Programss.pptx
BEVARAVASUDEVAAP1813
 
Unit 4 final
Unit 4 finalUnit 4 final
Unit 4 final
sietkcse
 
Oracle RI ETL process overview.
Oracle RI ETL process overview.Oracle RI ETL process overview.
Oracle RI ETL process overview.
Puneet Kala
 
Linux Assignment 3
Linux Assignment 3Linux Assignment 3
Linux Assignment 3
Diane Allen
 
assignment character education assignment
assignment character education assignmentassignment character education assignment
assignment character education assignment
tsegayeblen57
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming
Rokonuzzaman Rony
 
Unit-III(Design).pptx
Unit-III(Design).pptxUnit-III(Design).pptx
Unit-III(Design).pptx
Fajar Baskoro
 
Java programming concept
Java programming conceptJava programming concept
Java programming concept
Sanjay Gunjal
 
UNIT-1.pptx python for engineering first year students
UNIT-1.pptx python for engineering first year studentsUNIT-1.pptx python for engineering first year students
UNIT-1.pptx python for engineering first year students
SabarigiriVason
 
Exhibit design and programming skills to build and automate business solution...
Exhibit design and programming skills to build and automate business solution...Exhibit design and programming skills to build and automate business solution...
Exhibit design and programming skills to build and automate business solution...
sramani6
 
Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2
Rajeev Rastogi (KRR)
 
Go Faster With Native Compilation
Go Faster With Native CompilationGo Faster With Native Compilation
Go Faster With Native Compilation
PGConf APAC
 
Design concepts and principles
Design concepts and principlesDesign concepts and principles
Design concepts and principles
saurabhshertukde
 
Tasks, functions and User Defined Programss.pptx
Tasks, functions and User Defined Programss.pptxTasks, functions and User Defined Programss.pptx
Tasks, functions and User Defined Programss.pptx
BEVARAVASUDEVAAP1813
 
Unit 4 final
Unit 4 finalUnit 4 final
Unit 4 final
sietkcse
 
Ad

Recently uploaded (20)

CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Ad

software design principles

  • 1. SOFTWARE DESIGN PRINCIPLES CRISTAL NGO ICT2106 – SOFTWARE DESIGN – WEEK 2
  • 2. PREVIOUSLY IN ICT2106 –What is software design? –Importance of software design –Software design process –What is a good design/software/process 2
  • 3. READING – Software engineering design, Carlos Otero, Chapter 1 (Software Design Fundamentals) 4
  • 4. GENERAL DESIGN PRINCIPLES 1. Modularization 2. Abstraction 3. Encapsulation 4. Coupling 5. Cohesion 6. Separation of interface and implementation 7. Sufficiency 8. Completeness 5
  • 5. PRINCIPLE #1: MODULARIZATION Modularization is the process of continuous decomposition of the software system until fine-grained components are created. When you modularize a design, you are also modularizing the requirements, programming and test cases. 6
  • 6. PRINCIPLE #2: ABSTRACTION Abstraction is “a view of an object that focuses on the information relevant to a particular purpose and ignores the remainder of the information” 7
  • 7. ABSTRACTION Abstraction can be employed to extract essential characteristics of: Procedures or behavior Data 8
  • 8. PROCEDURAL ABSTRACTION SEND(client, server, message) 1. Client retrieves the serverʼs information, 2. opens a TCP/IP connection, 3. sends the message, waits for response, and 4. closes the connection Simplifies reasoning about behavioural operations containing a sequence of steps 9
  • 9. DATA ABSTRACTION MESSAGE is an example of the data abstraction; the details of a MESSAGE can be deferred to later stages of the design phase. SEND(client, server, message) Simplifies reasoning about structural composition of data objects 10
  • 10. PRINCIPLE #3: ENCAPSULATION Encapsulation deals with providing access to services of abstracted entities by exposing only the information that is essential to carry out such services while hiding details of how the services are carried out. Information hiding: Internal details (state, structure, behavior) become the objectʼs secret 11
  • 11. ENCAPSULATION & INFORMATION HIDING – One can think of information hiding as the principle and encapsulation as the technique – Encapsulation is the public interface that defines how an object can be used, and how its data is derived. – Information Hiding prevents an external object from using the derived data altogether 13
  • 12. ENCAPSULATION & INFORMATION HIDING class Automobile extends Vehicle { public final static int EMPTY = 0; public final static int FULL = 1; public int tank = EMPTY; } Neither Encapsulation nor Information Hiding 14
  • 13. ENCAPSULATION & INFORMATION HIDING class Automobile extends Vehicle { public final static int EMPTY = 0; public final static int FULL = 1; private int tank = EMPTY; public int getTankStatus() { return this.tank; } public void setTankStatus( int status ){ this.tank = status; } } The status of the tank is now encapsulated, but NOT HIDDEN from the rest of the system. 15
  • 14. class Automobile extends Vehicle { private final static int EMPTY = 0; private final static int FULL = 1; private int tank = EMPTY; private int tank() {…} private void tank( int status ) {…} public void fillUp() { tank( FULL ); } public void depleteOzone() throws GasExhaustedException { if( tank() == FULL ) { tank( EMPTY ); } else { throw new GasExhaustedException(); } } } A simple interface fully Encapsulates and Hides Information: fillUp() and depleteOzone(). No other object in the system can use, or know the state of, the gas tank. 16
  • 15. MODULARIZATION, ABSTRACTION & ENCAPSULATION Focus on essential characteristics of entities Enforce that we only expose essential information 17
  • 16. PRINCIPLE #4: COUPLING The higher the coupling The higher the dependency Refers to the manner and degree of interdependence between software modules. Measurement of dependency between units. 18
  • 17. COUPLING: DEGREE OF DEPENDENCE AMONG COMPONENTS No dependencies Loosely coupled- some dependencies Highly coupled- many dependencies High coupling makes modifying parts of the system difficult, e.g., modifying a component affects all the components to which the component is connected 19
  • 18. Content Common Control Stamp Data TIGHT COUPLING LOOSE COUPLING More interdependency More coordination More information flow Less interdependency Less coordination Less information flow 21
  • 19. CONTENT COUPLING Definition: A module directly references the content of another module 1. Module p modifies a statement of module q 2. Module p refers to local data of module q (in terms of a numerical displacement) 3. Module p branches to a local label of module q 22
  • 20. COMMON COUPLING – Using global variables (i.e., global coupling) – All modules have read/write access to a global data block – Modules exchange data using the global data block (instead of arguments) Single module with write access where all other modules have read access is not common coupling 23
  • 21. COMMON COUPLING - EXAMPLE while( global_variable > 0 ){  switch( global_variable ){  case 1: function_a(); break; case 2: function_b(); break; ... case n: ... } global_variable++; } If function_a(), function_b(), etc can modify the value of global variable, then it can be extremely difficult to track the execution of this loop 24
  • 22. STAMP COUPING Occurs when too much information is passed to a function. typedef struct rectangle { int length; int width;  int area; int perimeter; int color; double diagonal; char symbol; } RECTANGLE; RECTANGLE CalcArea (RECTANGLE r) { r.area = r.width * r.length; return r; } We are passing an entire RECTANGLE to this function, even though the function really does not need to see or modify all of the members. 25
  • 23. DATA COUPLING Process Results Calculate Grade mark grade Two modules are data coupled if they communicate by passing parameters and no extra data are passed. Data coupling exhibits the properties that all parameters to a module are either simple data types, or in the case of a record being passed as a parameter, all data members of that record are used/required by the module. 26
  • 24. DATA COUPLING – MORE EXAMPLE typedef struct rectangle { int length; int width;  int area; int perimeter; int color; double diagonal; char symbol; } RECTANGLE; int CalcArea(int width, int length) { int area; area = width * length; return area; } This is a better way to write the previous program. Here we will be passing and returning only primitive data types. They are all that is really needed by the functions and now the functions are more general, too. 27
  • 25. PRINCIPLE #5: COHESION – The manner and degree to which the tasks performed by a single software module are related to one another. – Measures how well design units are put together for achieving a particular tasks. 28
  • 26. COUPLING AND COHESION –Cohesion is defined as the degree to which all elements of a module, class, or component work together as a functional unit. High cohesion is good, and low cohesion is bad. –Coupling is defined as the degree of interdependence between two or more classes, modules, or components. Tight coupling is bad, and loose coupling is good. 29
  • 27. LOOSE COUPLING - HIGH COHESION 30 In essence, high cohesion means keeping parts of a code base that are related to each other in a single place. Low coupling, at the same time, is about separating unrelated parts of the code base as much as possible.
  • 29. COINCIDENTAL COHESION This is the weakest form of cohesion. Its element have no meaningful relationship. 32
  • 30. PROCEDURAL COHESION – A module has procedural cohesion if all the operations it performs are related to a sequence of steps performed in the program. – For example, if one of the sequence of operations in the program was “read input from the keyboard, validate it, and store the answers in global variables”, that would be procedural cohesion. 33
  • 32. INFORMATIONAL COHESION – Information cohesion describe a module performing a number of operations, each with a unique entry point and independent code, and all operations are performed on the same data. – In information cohesion, each function in a module must perform exactly one action 35
  • 33. INFORMATIONAL COHESION The Object-oriented approach naturally produce designs with informational cohesion – Each object in general has its own source code/file – Each object operates on its own data which are defined within the object. – Each member function of the object should perform one unique action/operation/function. 36
  • 35. TYPES OF CODE FROM A COHESION AND COUPLING PERSPECTIVE 38 http://enterprisecraftsmanship.co m/2015/09/02/cohesion- coupling-difference/
  • 36. POORLY SELECT BOUNDARIES as the result of High Coupling Low Cohesion 39 The problem here is that they are selected improperly and often do not reflect the actual semantics of the domain.
  • 37. DESTRUCTIVE DECOUPLING as the result of low coupling, low cohesion 40 It sometimes occurs when a programmer tries to decouple a code base so much that the code completely loses its focus:
  • 38. SEPARATION OF INTERFACE AND IMPLEMENTATION This principle involves defining a component by specifying a public interface (known to the client of the component) that is separate from the details of how the component is realized. Interface Implementation 42
  • 39. SEPARATION VS. ENCAPSULATION How is this principle different from Encapsulation? 43
  • 40. SEPARATION VS. ENCAPSULATION “During encapsulation, interfaces are created to provide public access to services provided by the design unit while hiding unnecessary details, which include implementation. While encapsulation dictates hiding the details of implementation, the principle of separation dictates their separation, so that different implementation of the same interface can be swapped to provide modified or new behavior.” 44
  • 41. PRINCIPLE #7,8: COMPLETENESS AND SUFFICIENCY – Completeness measures how well designed units provide the required services to achieve the intent (no less). – Sufficiency measures how well the designed units are at providing only the services that are sufficient for achieving the intent (no more). 45
  • 42. Apple has really come up with lots of smart ideas to improve simple app like photo editing which reduces the number of clicks required and still get the work done. Completenessandsufficiency 46
  • 43. PRACTICAL DESIGN CONSIDERATIONS Design for minimizing complexity Design for change 49