Varieties of Cohesion

Lets do the same analysis with cohesion. There are a variety of different ways that methods within an object can be related to each. It could be that they are just tossed together, this is terms coincidental cohesion. It could be that they have some logical relationship, such as a variety of functions to compute mathematical functions, but do not share any data or inner functionality. It could be that items are combined because they happen at the same time, such as initialization code.

It could be that items are combined because they must communicate with each other. It could be that functions are combined in one object because they must be invoked in sequence.

It could be that methods are combined in an object because they share some common behavior, perhaps a common internal function.

Finally, it could be that methods are combined within an object because they share a common data area.

[audio] [real] Text to accompany slide7, in Chapter 17 of An Introduction to Object-Oriented Programming