lecture 15
DESCRIPTION
TRANSCRIPT
![Page 1: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/1.jpg)
Intduction to Software
Engineering
Lecture 15
![Page 2: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/2.jpg)
Cohesion
![Page 3: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/3.jpg)
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
![Page 4: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/4.jpg)
Manager Objectsand
IntelligenceDistribution
![Page 5: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/5.jpg)
Consider a heat regulatory system for a room
as shown below.
Intelligence Distribution
![Page 6: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/6.jpg)
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
![Page 7: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/7.jpg)
Intelligence Encapsulation
![Page 8: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/8.jpg)
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
![Page 9: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/9.jpg)
Intelligence Distribution
![Page 10: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/10.jpg)
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.
![Page 11: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/11.jpg)
Object Modeling using
Coad’s Methodology
![Page 12: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/12.jpg)
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
![Page 13: Lecture 15](https://reader036.vdocuments.mx/reader036/viewer/2022062615/548b00e7b479599e5b8b45ad/html5/thumbnails/13.jpg)
Container Objects
Folder, Shelf, etc
Tangible Things Account, Book, Calendar, Cash Box, Cash
Drawer, Item, Plan, Procedure, Product, Schedule, Skill, Tools, etc
Select Object