Skip to main content

Posts

Showing posts from March, 2006

Object Primer - Cohesion

Tip : An object should be highly cohesive. Cohesion is a measure of how much an item say for eg. a class or method, makes sense. Objects with low cohesion are more likely to be changed. A method is highly cohesive if it does one thing and only one thing.

Object Primer - Coupling

Object coupling describes the degree of interrelationships among the objects that make up a system. The more any one object knows about any other object in the system, the tighter the coupling is between those objects. In other words, coupling is a measure of how two items, such as classes or methods, are interrelated. When one class depends on another class the are said to be coupled. When one class interacts with another class, but does not know have any knowledge of the implementation details of the other class they are said to be loosely coupled. When one class relies on the implementation of another class, they are said to be tighly coupled. Point: Always try for loose coupling among objects. This can be achieved by programming to a common interface(super type).