Top Banner
Intduction to Software Engineering Lecture 15
13
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 15

Intduction to Software

Engineering

Lecture 15

Page 2: Lecture 15

Cohesion

Page 3: Lecture 15

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

Manager Objectsand

IntelligenceDistribution

Page 5: Lecture 15

Consider a heat regulatory system for a room

as shown below.

Intelligence Distribution

Page 6: Lecture 15

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

Intelligence Encapsulation

Page 8: Lecture 15

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

Intelligence Distribution

Page 10: Lecture 15

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

Object Modeling using

Coad’s Methodology

Page 12: Lecture 15

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

Container Objects

Folder, Shelf, etc

Tangible Things Account, Book, Calendar, Cash Box, Cash

Drawer, Item, Plan, Procedure, Product, Schedule, Skill, Tools, etc

Select Object