OOAD 101 Lesson 4: Understanding cohesion
April 29th, 2006
acomplia online cialis cost cialis online pharmacy viagra for order cheapest accutane cheap cialis viagra uk purchase viagra online where to order cialis purchase viagra no rx cheap price cialis accutane sale find discount cialis find discount viagra online generic cialis cheap cialis in uk buy cialis from canada acomplia online stores viagra for sale lowest price for cialis buy viagra on line price of viagra drug viagra online purchase 25mg viagra viagra cost viagra cheap price purchase cialis online buy viagra lowest price pharmacy viagra best price for viagra purchase accutane cialis pills tablet viagra cheap acomplia online order viagra overnight delivery buy cialis overnight delivery viagra in bangkok cialis bangkok purchase cialis no rx cheap cialis no rx purchase acomplia online cheap generic cialis cheapest cialis viagra in us cialis in bangkok order viagra online best price viagra viagra malaysia where to buy acomplia cheapest cialis prices cialis cheap buying cialis order generic viagra viagra order buying generic viagra no prescription cialis buy accutane buy viagra no rx buy cheapest viagra buy acomplia cheap order viagra no prescription required buy viagra in us 20mg cialis order viagra in us acomplia cheap buying viagra viagra cheap buy cheap viagra online fda approved viagra cialis information cost of viagra find cheap cialis cialis from canada purchase viagra overnight delivery acomplia discount fda approved cialis viagra rx find no rx cialis viagra discount certified cialis cialis without a prescription accutane acomplia pharmacy cialis overnight shipping viagra australia sale cialis buy sildenafil citrate buy cialis from us online viagra cialis soft acomplia prices buy discount cialis viagra pill viagra prices buy viagra overnight delivery online cialis order cialis cheap online discount viagra overnight delivery viagra online without prescription compare viagra prices online cheapest generic cialis accutane online overnight cialis cheap cialis without prescription buy sildenafil in uk viagra no rx cialis cheap price 50mg viagra buy accutane online erectile dysfunction cheap viagra overnight delivery cheap cialis tablets viagra pharmacy online acomplia without a prescription cheap accutane tablets buy cialis without prescription lowest price acomplia cialis tablet buy generic accutane find cialis without prescription order accutane cheap cialis overnight delivery cialis price cialis from india cialis no rx buy discount cialis online cialis overnight buy acomplia without prescription cialis tablets cheap viagra in usa buy viagra in canada cialis pharmacy online order cialis in us discount cialis 20 mg cialis acomplia online cheap cheapest viagra online cialis prescription order cialis on internet buy sildenafil in spain buy generic cialis cheap cialis in canada viagra tablets accutane without prescription cialis canada buy cheap acomplia online cheap viagra cheap cialis pharmacy find cialis on internet acomplia prescription buy cialis cheap order cheap cialis online find cialis no prescription required viagra overnight delivery buy viagra low price compare cialis prices 25 mg viagra order viagra no rx viagra online buy cialis no rx impotence treatment impotence cure viagra overnight online pharmacy cialis viagra online cheap find cialis online generic cialis online no rx cialis accutane generic cheapest acomplia prices buy viagra online cheap buy viagra internet acomplia no prescription pfizer viagra drug cialis online purchase order discount cialis cialis 10mg best price for cialis cheap viagra from usa find discount viagra cialis pill order viagra without prescription viagra generic purchase viagra without prescription buy acomplia online accutane cheap order viagra from canada cialis online without prescription cheap accutane cialis side effects cialis for sale buy cheap accutane online cialis generic discount cialis without prescription buy viagra from canada buy cialis internet discount viagra no rx viagra without a prescription drug cialis cialis pharmacy buy cialis generic cialis prices discount accutane order cialis no prescription impotence drugs cost viagra acomplia generic buy viagra online impotence medication order cialis from canada buy discount viagra acomplia acomplia pills purchase accutane online pharmacy online buy sildenafil internet buy accutane cheap viagra canada discount cialis online order cialis overnight delivery where to buy viagra cheap accutane online find no rx viagra cheap cialis from uk lowest price for viagra cheap viagra from canada approved cialis pharmacy 10 mg cialis viagra in uk cialis vs viagra cialis internet cheapest viagra prices accutane prescription buy cialis in us low cost cialis cialis buy online pharmacy cialis buying generic cialis purchase cialis overnight delivery buy discount viagra online order no rx viagra acomplia without prescription viagra buy order viagra from us viagra internet find discount cialis online acomplia for sale purchase cialis without prescription cialis drug discount viagra accutane prices buy sildenafil canada viagra in malaysia accutane online stores generic drugs buy viagra generic cialis purchase cialis us viagra medication price of accutane cheap cialis pill viagra no prescription find viagra buy cialis online cheap cheap cialis from canada cheap generic viagra price of cialis sale viagra viagra free sample order viagra order acomplia online where to order viagra viagra approved cialis for order buy sildenafil cheap buy accutane without prescription discount viagra without prescription cheap cialis from usa buy viagra no prescription required cialis discount cheap viagra on internet order generic cialis buying cialis online accutane without a prescription buy cialis lowest price viagra no rx required buy generic viagra online purchase cialis viagra buy drug order cialis without prescription viagra us 10mg cialis cheap acomplia tablets buy sildenafil in canada find viagra without prescription cialis overnight delivery buy viagra cheap cialis cheapest price cialis sale lowest price cialis cheapest generic viagra viagra soft tab no rx viagra cheap cialis no prescription purchase viagra viagra sale viagra india find viagra no prescription required impotence pills cialis 20mg 100 mg viagra buy cheap accutane buy cialis low price compare viagra prices cheapest viagra price impotence cheap viagra tablet tablet cialis order discount viagra viagra overnight shipping order viagra on internet buy cheap cialis online cost cialis buy sildenafil low cost order cialis no rx cheap viagra in uk cialis medication generic viagra cheap buy sildenafil online buy cheapest cialis on line order cialis no prescription required viagra drug buy viagra without prescription buy cialis on internet viagra cheap drug cheap viagra no prescription cheap viagra in canada cheap generic acomplia cheap viagra internet viagra pills cheap cialis in uk order cheap viagra online buy cialis from india cheap viagra no rx cheapest generic viagra online lowest price viagra cheap cialis in usa viagra sales order accutane online buy and purchase sildenafil online online pharmacy viagra viagra in australia certified viagra cialis malaysia viagra cheapest price cialis no rx required buy cheap acomplia buy sildenafil online without a prescription discount viagra online no prescription viagra viagra tablet viagra from india viagra cheap cialis internet order cialis 50 mg viagra buy cialis in canada order discount cialis online cialis no online prescription approved viagra pharmacy cialis soft tab cialis no prescription buy cialis order cheap cialis 100mg viagra order cialis online compare cialis prices online cheap viagra tablets cheap price viagra cialis cheap viagra online find viagra on internet cialis 20 mg viagra side effects cheap acomplia cialis without rx cialis without prescription cialis 10 mg viagra bangkok purchase acomplia cialis free delivery cheapest viagra buy viagra cialis india viagra vendors low cost viagra order viagra cheap online cheap viagra from uk generic accutane cheapest accutane prices viagra vs cialis generic acomplia accutane pills buy generic viagra generic viagra online generic viagra accutane discount find viagra online find cialis accutane pharmacy viagra online stores cialis buy order viagra in canada cialis online cheap viagra soft find cheap cialis online cheap viagra without prescription order viagra no prescription buy cheapest cialis order cialis in canada cheapest sildenafil citrate cialis uk cialis free sample cialis online review buy generic acomplia price of acomplia drug viagra generic cialis viagra no online prescription free viagra viagra information buy viagra from us buy viagra on internet cheapest acomplia order acomplia viagra buy online viagra online review where to buy cialis buy cheapest viagra online viagra without rx cialis approved viagra pharmacy order cheap viagra buy cialis online discount cialis no rx cheap viagra pill buy generic cialis online cialis online buy no rx viagra viagra online pharmacy cialis online stores buy cheap cialis buy cheapest cialis online buy cheap viagra accutane for sale cialis in australia buy cheap cialis internet acomplia sale buy viagra us overnight viagra lowest price accutane online accutane online acomplia find cheap viagra online best price cialis buy cheap viagra internet viagra free delivery cheap cialis on internet buy viagra from india cialis rx buying viagra online cheap generic accutane find cheap viagra where to buy accutane cialis australia cheapest cialis online order no rx cialis viagra purchase cialis vendors discount acomplia cialis cheap drug discount cialis overnight delivery cialis sales cialis buy drug cheapest generic cialis online buy cheapest viagra on line cheap cialis online cheap viagra pharmacy accutane online cheap buy acomplia viagra without prescription cheap cialis tablet cheapest cialis price buy no rx cialis cialis in us buy cialis on line free cialis order cialis from us cialis in malaysia accutane no prescription order discount viagra online cost of cialis buy cialis us cialis order viagra from canada viagra prescription buy cialis no prescription required viagra priceCohesion tells us how narrowly defined an object is. An object with high cohesion is defined for one purpose and it only performs that purpose. An object with low cohesion tends to try to do a lot of different things. Cohesion also tells us if too many objects are attempting to do the same thing. So, if I have a system of objects to implement my NetRunner game and every card has a unique class with a rendering method and that method is nearly identical in all classes, then that system has low cohesion because too many objects are doing the same thing.
Course Outline:
- OOAD 101 Lesson 1: What is an object and what is object-oriented?
- OOAD 101 Lesson 2: Coupling and cohesion trump reuse and inheritance
- OOAD 101 Lesson 3: Understanding Coupling
- OOAD 101 Lesson 4: Understanding cohesion
The very difficult question is how does one objectively measure cohesion? For example, take the AccountReceivables class shown here:

I can tell you that the cohesion is pretty low, but why? The industry has done a poor job at providing measures of cohesion. Just look at the depressing conclusions of this abstract from an IEEE paper on measures of cohesion:
It is a little over ten years since Chidamber and Kemerer’s object-oriented (OO) metric suite which included the Lack of Cohesion Of Methods (LCOM) metric was first proposed [9]. Despite considerable effort both theoretically and empirically since then, the software engineering community is still no nearer finding a generally accepted definition or measure of OO cohesion. Yet, achieving highly cohesive software is a cornerstone of software comprehension and hence, maintainability. In this paper, we suggest a number of suppositions as to why a definition has eluded (and we feel will continue to elude) us. We support these suppositions with empirical evidence from three large C++ systems and a cohesion metric based on the parameters of the class methods; we also draw from other related work. Two major conclusions emerge from the study. Firstly, any sensible cohesion metric does at least provide insight into the features of the systems being analysed. Secondly however, and less reassuringly, the deeper the investigative search for a definitive measure of cohesion, the more problematic its understanding becomes; this casts serious doubt on the use of cohesion as a meaningful feature of object-orientation and its viability as a tool for software comprehension.
Most engineers essentially eyeball it. The more experienced engineers, mostly through instinct, know exactly what to refactor to fix the design issue, but the rest are left to struggle.
In lesson 2, I stated my position that OOAD should be done via examing coupling and cohesion and creating refactoring and design plans based on that analysis. In lesson 3, I provided an objective measure of coupling. To continue on this path, we must have an objective measure of cohesion. And since the industry has not provided one, through the years I have had to develop one myself. The method is called cohesion grid analysis.
The keys is to classify behavior into primary dimensions. For the systems we write today, there are three primary dimesions:
- Architecture Categories: This is a list of the primary architecture categories For example, if the system architecture was MVC, then the there would be three items in this dimension (model, view, controller).
- Design Pattern Category: These are the categories from the Design Patterns book I mentioned in Lesson 1. The categories are creational, structural, and behavioral.
- Domain: This is a list of the primary types of objects in the application domain. For example, in the NetRunner game this would include the card types like Operation Cards, Agendas, Ice, etc.
To perform the analyis, construct a grid of two of the three dimensions. When I focus on infrastructure, the grid is of architecture and design pattern categories. When I am focusing on application behavior, it is typically domain and architecture.
So going back to our AccountsReceivable class, how do we measure its cohesion? Lets look at an “architecture by patterns grid”. To do that, though, we need to know what our architecture categories are. Say we based our architecture off of MVC and came up with the following categories:
- Game Renderer: These component renders the game board.
- Game Logic: These components execute the game logic.
- Game Model: These components represent the game board objects (such as cards, bits, data forts, etc.).
Given that, then our grid will be:
| Creational | Structural | Behavioral | |
| Game Renderer | |||
| Game Logic | |||
| Game Model |
The more grids an object fills, the lower its cohesion. Furthermore, the more objects in the same grid, the lower the system cohesion.
Here is the grid analysis of the AccountsReceivable:
| Creational | Structural | Behavioral | |
| Game Renderer | X | ||
| Game Logic | X | ||
| Game Model | X | X |
To fill it in we asked the following questions:
- Is the object creating game rendering objects? no
- Is the object used to represent the game rendering layout? no
- Is the object used to perform the rendering operation? yes
- Is the object used to create game logic objects? no
- Is the object used to represent the game logic state? no
- Is the object used to perform game logic operations? yes (note the play method would have to do both game logic moves, such as resolving by yielding control to the next player AND game object behavior such as adding 9 bits to the bit pool).
- Is the object used to create game model objects? no
- Is the object used to represent game object state? yes
- Is the object used to perform game object operations? yes
So the cohesion of this object is (number of grids checked/num total grids) or 4/9. We can now use this analysis to create a refactoring plan. We can set the goal of the plan to upgrade the cohesion to 3/9. And we may decide to do that by altering the design such that our AccountsRecievable object (which is really a game model object) no longer be responsible for the behavior of game logic.
Entry Filed under: Software Development
1 Comment Add your own
1. Sonjaya Tandon » FR&hellip | October 12th, 2006 at 5:41 pm
[…] In XCF Version 5, these actions were accomplished with three separate sub-systems. It turns out that that was a design error. From a cohesion point of view, the behaviors were sliced to thin. (For more on cohesion, see the OOAD lessons). That is XCF 5 has too many objects to represent these actions. The mistake was in viewing these actions as three different things. They are really one thing, and that is request processing. […]
Leave a Comment
You must be logged in to post a comment.
Trackback this post | Subscribe to the comments via RSS Feed