Tuesday, December 7, 2010

Architecture - Cohesion(High) & Coupling(Low)

------------------------------------------------------------------------------------------------------------

What is High/Weak Cohesion:

 

High-Cohesion is achieved, when logically related entities, such as classes and its methods, are grouped together. Similarly, a component contains logically related classes.

This results in lesss round trips because the classes or components are logically grouped and may end up residing in same tiers. Thus to complete a operation, no local or remote calls are required.

 

Weak cohesion among components tends to result in more round trips because the classes or components are not logically grouped and may end up residing in different tiers.

This can force us to require a mix of local and remote calls to complete a logical operation.

------------------------------------------------------------------------------------------------------------

 

Cohesion measures how many different components take advantage of shared processing and data.

Coupling is a degree of dependency (at design or run time) that exists between parts of a system.

 

Reducing Coupling and increasing Cohesion are two key principles to increasing application scalability.

The 'Major Design Fact' that provides these two important design factors - High Cohesion & Low Coupling and thus the Increased Scalability is – Layered Design/Layering.

 

Using Layering, to partition your application ensures that your presentation, business, and data access logic are not interspersed.

This logical seperation leads to a High Cohesive Design in which related classes and data are located close to each other, generally within a single boundary. This helps reduce/optimize the use of expensive local/remote calls.

 

Layering, also ensures that your presentation, business, and data access logic are loosely coupled.

This logical seperation leads to a Loosely Coupled Design.

If you have tight coupling and need to make changes, the changes are likely to ripple across the tightly coupled components. With loosely coupled components, changes are limited because the complexities of individual components are encapsulated from other components/layers. In addition, loose coupling provides greater flexibility to choose optimized strategies for performance and scalability for different components of your system independently.

 

Recommendations - To ensure appropriate degrees of coupling and cohesion.

 

1.       Design for Loose Coupling.

2.       Design for High Cohesion.

3.       Prefer Layered Design.

 

Design for Loose Coupling

Aim to minimize coupling within and across your application components. Making changes with tight coupling are likely to ripple across the tightly coupled components.

In addition, loose coupling provides greater flexibility to choose optimized strategies for performance and scalability for different components of your system independently

 

Patterns & Principles that enable loose coupling are:

 

·         At Business Layer , Use Abstraction: The abstraction can be implemented using

·         Public Object Interfaces,

·         Common Interface Definitions,

·         Abstract Base Classes, or

·         Messaging

·         Separate interface from implementation – By providing Facades.

 

·         For Web applications - Consider a Message-based communication between the presentation layer and the business layer

 

Design for High Cohesion

High-Cohesion is achieved, when logically related entities, such as classes and its methods, are grouped together. Similarly, a component contains logically related classes.

This results in lesss round trips because the classes or components are logically grouped and may end up residing in same tiers. Thus to complete a operation, no local or remote calls are required.

 

Layering: Prefer Layered Design

Using Layering, to partition your application ensures that your presentation, business, and data access logic are not interspersed.

This logical seperation leads to a High Cohesive Design in which related classes and data are located close to each other, generally within a single boundary. This helps reduce/optimize the use of expensive local/remote calls.

 

Layering, also ensures that your presentation, business, and data access logic are loosely coupled.

This logical seperation leads to a Loosely Coupled Design.

 

 

Hope this helps.

 

Regards,

Arun Manglick

 

No comments:

Post a Comment