Friday, July 15, 2011

Design Patterns: Cohesion And Coupling

Posting a few articles regarding basic design frameworks and patterns. This one is from MSDN Magazine regarding cohesion and coupling.

  1. Decrease Coupling - Aspire to design loosely coupled classes or class which are not dependent on one another.
  2. Eliminate Inappropriate Intimacy - Careful with business logic class which needs too much information regarding data access.
  3. Increase Cohesion - Make the code inside a class directly related.

Observation of decrease coupling/increase cohesion creates these positive benefits:
  • Keep things that have to change together as close together in the code as possible.
  • Allow unrelated things in the code to change independently.
  • Minimize duplication in the code.

No comments: