Monday, October 18, 2010

Project 11 - Problems Solving Techniques (part 2)

Coupling and cohesion are measures of how much each program modules relies on each one of the other modules. Usually the two are contrasted, that is to say low coupling often correlates with high cohesion and vice versa.

Coupling is how much one module is dependent on another module. If they have high coupling, that means one module modifies or relies on the internal workings of another module (e.g. accessing local data of another module), so if you were to change the way the second module processes data it would lead to changing the dependent module. Low coupling means they share little data and therefore changes in one module would not affect another module very much.

Disadvantages of coupling:
  • A change in one module usually causes a ripple effect of changes in other modules
  • Assembly of modules might require more effort due to increased inter-module dependency
  • Particular modules may be difficult to test independently due to their dependence on other modules
Cohesion is how strongly-related or focused the functionality of a single module is. If the methods that serve the given class tend to have many similarities, than the class is said to have high cohesion. In a highly-cohesive system, code readability and reuse is increased, whilst complexity is kept manageable. High cohesion would mean the parts of a module are grouped because they all contribute to a single well-defined task of the module. Low cohesion would be that they have been grouped arbitrarily, and that the only relationship between the parts is that they have been grouped together.

Coupling is comparable to playing in a team sport where formation is important, such as American football. Every player needs to be in a certain position for a play to work out, but if you change one player's position, usually many players also change around to match him so you still have a unity in your formation and play. This same thing works with other sports as well, in baseball everyone needs to be in their position to cover all the areas the ball could be hit to and take it back into the center to achieve the out, and everyone has to turn based on who has the ball and where they're throwing it to in order to achieve the common goal of outs so they can take their turn up at bat.

Cohesion would be like a relay race with different parts, like part one the competitors skateboard, part two they roller blade and part three they bike. Each member of the team is would be specialized for the section they'd be racing in, and have very little action with each other, just clapping hands or something to pass off lead. The only thing they share in common is being grouped together as land vehicle racers, because they all race on land with some mode of transportation. All fairly similar, but slightly different depending on the specific part. Low cohesion would be like a swimmer, a runner and a biker, they share very little in common, but have been semi-arbitrarily grouped together as a "race team".

1 comment:

  1. Borgata Hotel Casino & Spa Review & Bonus Codes 2021
    The Borgata 토토 검증 먹튀 랭크 Hotel Casino & Spa is a casino located in Atlantic 가상화폐란 City, New Jersey, in the United States. The casino has a number 벳365코리아 of poker mobile bet365 rooms, 비윈티비

    ReplyDelete