SlideShare a Scribd company logo
1 of 13
Lecture 15

Cohesion

 As mentioned earlier, strong cohesion implies that all
parts of a component should have a close logical
relationship with each other. That means, in case some
kind of change is required in the software, all the related
pieces are found at one place.
 A class will be cohesive if most of the methods defined in
a class use most of the data members most of the time. If
we find different subsets of data within the same class
being manipulated by separate groups of functions then
the class is not cohesive and should be broken down as
shown in the above slide.
Example of Cohesion

Manager Objects
and
Intelligence
Distribution

 Consider a heat regulatory system for a room as
shown below.
Intelligence Distribution

 In this case, the room is not encapsulated as one
entity and three different objects namely Desired
Temp, Actual Temp, and Occupancy maintain
necessary information about a room. In this case the
Heat Flow Regulator has to communicate with three
different objects.
Intelligence Distribution

Intelligence Encapsulation

 If we encapsulate the three objects into one Room object
as shown in the above slide, then the Heat Flow Regulator
will need to communicate with one object, hence the
overall coupling of the system will be reduced.
 This happened because in the first case intelligence is
distributed while in the second case it is encapsulated.
However, the control is still centralized as the Heat Flow
Regulator has the control logic that first analyses the
values from different queries and then makes a decision
about turning the furnace on of off. We can improve the
situation even further by delegating this responsibility to
the Room object as shown below.
Intelligence Encapsulation

Intelligence Distribution

Intelligence Distribution
 By doing that we reduce coupling even further
because now we have made Room more cohesive by
putting the function with the related data and have
thus reduced the number and types of messages
being sent from the regulator to the room.

Object Modeling using
Coad’s Methodology

 Actor
 Person, Organization, etc
 Participants
 Role (agent, applicant, buyer, etc)
 Places
 Airport, Assembly-line, Bank, City, etc
 Transactions
 Agreement, Authorization, Delivery, Deposit, Order,
Payment, etc
Select Object

 Container Objects
 Folder, Shelf, etc
 Tangible Things
 Account, Book, Calendar, Cash Box, Cash Drawer,
Item, Plan, Procedure, Product, Schedule, Skill, Tools,
etc
Select Object

More Related Content

Viewers also liked

Lecture 07
Lecture 07Lecture 07
Lecture 07Rana Ali
 
Lecture 06
Lecture 06Lecture 06
Lecture 06Rana Ali
 
Lecture 05
Lecture 05Lecture 05
Lecture 05Rana Ali
 
Lecture 04
Lecture 04Lecture 04
Lecture 04Rana Ali
 
Lecture 10
Lecture 10Lecture 10
Lecture 10Rana Ali
 
Lecture 14
Lecture 14Lecture 14
Lecture 14Rana Ali
 
Software Engineering - Lecture 02
Software Engineering - Lecture 02Software Engineering - Lecture 02
Software Engineering - Lecture 02Asifuzzaman Hridoy
 
Software engineering lecture notes
Software engineering   lecture notesSoftware engineering   lecture notes
Software engineering lecture notesAmmar Shafiq
 
CSC426 - Software Engineering Lecture Note
CSC426   - Software Engineering Lecture NoteCSC426   - Software Engineering Lecture Note
CSC426 - Software Engineering Lecture NoteBro Shola Ajayi
 
Software engineering lecture notes
Software engineering lecture notesSoftware engineering lecture notes
Software engineering lecture notesSiva Ayyakutti
 

Viewers also liked (11)

Nlp
NlpNlp
Nlp
 
Lecture 07
Lecture 07Lecture 07
Lecture 07
 
Lecture 06
Lecture 06Lecture 06
Lecture 06
 
Lecture 05
Lecture 05Lecture 05
Lecture 05
 
Lecture 04
Lecture 04Lecture 04
Lecture 04
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Software Engineering - Lecture 02
Software Engineering - Lecture 02Software Engineering - Lecture 02
Software Engineering - Lecture 02
 
Software engineering lecture notes
Software engineering   lecture notesSoftware engineering   lecture notes
Software engineering lecture notes
 
CSC426 - Software Engineering Lecture Note
CSC426   - Software Engineering Lecture NoteCSC426   - Software Engineering Lecture Note
CSC426 - Software Engineering Lecture Note
 
Software engineering lecture notes
Software engineering lecture notesSoftware engineering lecture notes
Software engineering lecture notes
 

Similar to Lecture 15

A Smart Heating System for Energy Management using an Enhanced Kinetic User I...
A Smart Heating System for Energy Management using an Enhanced Kinetic User I...A Smart Heating System for Energy Management using an Enhanced Kinetic User I...
A Smart Heating System for Energy Management using an Enhanced Kinetic User I...Editor IJAIEM
 
17 slide grasp
17 slide grasp17 slide grasp
17 slide graspAfaq Ahmed
 
Application for Logical Expression Processing
Application for Logical Expression Processing Application for Logical Expression Processing
Application for Logical Expression Processing csandit
 
sustech.2022.8671326.docx
sustech.2022.8671326.docxsustech.2022.8671326.docx
sustech.2022.8671326.docxpranathiReddy61
 
A PROPOSED FUZZY LOGIC APPROACH FOR CONSERVING THE ENERGY OF DATA TRANSMISSIO...
A PROPOSED FUZZY LOGIC APPROACH FOR CONSERVING THE ENERGY OF DATA TRANSMISSIO...A PROPOSED FUZZY LOGIC APPROACH FOR CONSERVING THE ENERGY OF DATA TRANSMISSIO...
A PROPOSED FUZZY LOGIC APPROACH FOR CONSERVING THE ENERGY OF DATA TRANSMISSIO...IJCNCJournal
 
A Proposed Fuzzy Logic Approach for Conserving the Energy of Data Transmissio...
A Proposed Fuzzy Logic Approach for Conserving the Energy of Data Transmissio...A Proposed Fuzzy Logic Approach for Conserving the Energy of Data Transmissio...
A Proposed Fuzzy Logic Approach for Conserving the Energy of Data Transmissio...IJCNCJournal
 
12 couplingand cohesion-student
12 couplingand cohesion-student12 couplingand cohesion-student
12 couplingand cohesion-studentrandhirlpu
 
A fast-replica-placement-methodology-for-large-scale-distributed-computing-sy...
A fast-replica-placement-methodology-for-large-scale-distributed-computing-sy...A fast-replica-placement-methodology-for-large-scale-distributed-computing-sy...
A fast-replica-placement-methodology-for-large-scale-distributed-computing-sy...Cemal Ardil
 
Semantic IoT Semantic Inter-Operability Practices - Part 2
Semantic IoT Semantic Inter-Operability Practices - Part 2Semantic IoT Semantic Inter-Operability Practices - Part 2
Semantic IoT Semantic Inter-Operability Practices - Part 2iotest
 
Unit two concept of classes and objects
Unit two concept of classes and objects Unit two concept of classes and objects
Unit two concept of classes and objects Dr Chetan Shelke
 
Temporal Case Management 1998
Temporal Case Management  1998Temporal Case Management  1998
Temporal Case Management 1998David Tryon
 

Similar to Lecture 15 (19)

A Smart Heating System for Energy Management using an Enhanced Kinetic User I...
A Smart Heating System for Energy Management using an Enhanced Kinetic User I...A Smart Heating System for Energy Management using an Enhanced Kinetic User I...
A Smart Heating System for Energy Management using an Enhanced Kinetic User I...
 
Think about the "Genie"
Think about the "Genie"Think about the "Genie"
Think about the "Genie"
 
Sequence diagrams
Sequence diagramsSequence diagrams
Sequence diagrams
 
17 slide grasp
17 slide grasp17 slide grasp
17 slide grasp
 
SECh1214
SECh1214SECh1214
SECh1214
 
Application for Logical Expression Processing
Application for Logical Expression Processing Application for Logical Expression Processing
Application for Logical Expression Processing
 
OOSE
OOSEOOSE
OOSE
 
Spring Project Report
Spring Project ReportSpring Project Report
Spring Project Report
 
sustech.2022.8671326.docx
sustech.2022.8671326.docxsustech.2022.8671326.docx
sustech.2022.8671326.docx
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
A PROPOSED FUZZY LOGIC APPROACH FOR CONSERVING THE ENERGY OF DATA TRANSMISSIO...
A PROPOSED FUZZY LOGIC APPROACH FOR CONSERVING THE ENERGY OF DATA TRANSMISSIO...A PROPOSED FUZZY LOGIC APPROACH FOR CONSERVING THE ENERGY OF DATA TRANSMISSIO...
A PROPOSED FUZZY LOGIC APPROACH FOR CONSERVING THE ENERGY OF DATA TRANSMISSIO...
 
A Proposed Fuzzy Logic Approach for Conserving the Energy of Data Transmissio...
A Proposed Fuzzy Logic Approach for Conserving the Energy of Data Transmissio...A Proposed Fuzzy Logic Approach for Conserving the Energy of Data Transmissio...
A Proposed Fuzzy Logic Approach for Conserving the Energy of Data Transmissio...
 
12 couplingand cohesion-student
12 couplingand cohesion-student12 couplingand cohesion-student
12 couplingand cohesion-student
 
A fast-replica-placement-methodology-for-large-scale-distributed-computing-sy...
A fast-replica-placement-methodology-for-large-scale-distributed-computing-sy...A fast-replica-placement-methodology-for-large-scale-distributed-computing-sy...
A fast-replica-placement-methodology-for-large-scale-distributed-computing-sy...
 
Semantic IoT Semantic Inter-Operability Practices - Part 2
Semantic IoT Semantic Inter-Operability Practices - Part 2Semantic IoT Semantic Inter-Operability Practices - Part 2
Semantic IoT Semantic Inter-Operability Practices - Part 2
 
Unit two concept of classes and objects
Unit two concept of classes and objects Unit two concept of classes and objects
Unit two concept of classes and objects
 
Midterm Winter 10
Midterm  Winter 10Midterm  Winter 10
Midterm Winter 10
 
CIS-166 Midterm
CIS-166 MidtermCIS-166 Midterm
CIS-166 Midterm
 
Temporal Case Management 1998
Temporal Case Management  1998Temporal Case Management  1998
Temporal Case Management 1998
 

Lecture 15

  • 3.   As mentioned earlier, strong cohesion implies that all parts of a component should have a close logical relationship with each other. That means, in case some kind of change is required in the software, all the related pieces are found at one place.  A class will be cohesive if most of the methods defined in a class use most of the data members most of the time. If we find different subsets of data within the same class being manipulated by separate groups of functions then the class is not cohesive and should be broken down as shown in the above slide. Example of Cohesion
  • 5.   Consider a heat regulatory system for a room as shown below. Intelligence Distribution
  • 6.   In this case, the room is not encapsulated as one entity and three different objects namely Desired Temp, Actual Temp, and Occupancy maintain necessary information about a room. In this case the Heat Flow Regulator has to communicate with three different objects. Intelligence Distribution
  • 8.   If we encapsulate the three objects into one Room object as shown in the above slide, then the Heat Flow Regulator will need to communicate with one object, hence the overall coupling of the system will be reduced.  This happened because in the first case intelligence is distributed while in the second case it is encapsulated. However, the control is still centralized as the Heat Flow Regulator has the control logic that first analyses the values from different queries and then makes a decision about turning the furnace on of off. We can improve the situation even further by delegating this responsibility to the Room object as shown below. Intelligence Encapsulation
  • 10.  Intelligence Distribution  By doing that we reduce coupling even further because now we have made Room more cohesive by putting the function with the related data and have thus reduced the number and types of messages being sent from the regulator to the room.
  • 12.   Actor  Person, Organization, etc  Participants  Role (agent, applicant, buyer, etc)  Places  Airport, Assembly-line, Bank, City, etc  Transactions  Agreement, Authorization, Delivery, Deposit, Order, Payment, etc Select Object
  • 13.   Container Objects  Folder, Shelf, etc  Tangible Things  Account, Book, Calendar, Cash Box, Cash Drawer, Item, Plan, Procedure, Product, Schedule, Skill, Tools, etc Select Object