5,421,850 members and growing! (22,267 online)
Email Password   helpLost your password?
Development Lifecycle » Design and Architecture » General     Intermediate

Design loosely coupled modules - object oriented systems

By Milind Shingade

This articles explains coupling, explains classification of coupling and gives simple way to reduce each type of coupling.
Architect, Dev, Design

Posted: 28 Jul 2007
Updated: 28 Jul 2007
Views: 4,490
Bookmarked: 4 times
Announcements



Search    
Advanced Search
Sitemap
7 votes for this Article.
Popularity: 1.69 Rating: 2.00 out of 5
3 votes, 42.9%
1
3 votes, 42.9%
2
0 votes, 0.0%
3
0 votes, 0.0%
4
1 vote, 14.3%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article
Title:       Design loosely coupled modules - object oriented systems
Author:      Milind Shingade 
Email:       "mailto:milindshingade@yahoo.comMember%20ID">milindshingade@yahoo.com
Member:      18133
Language:    C++   
Platform:    Generic none
Technology:  None
Level:       Beginner
Description: This articles explains coupling,  explains classification of coupling and gives simple way to reduce each type of coupling. 
Section:     Application design 
SubSection:  General

Introduction

This article explains the coupling between the classes. It also explains the consequences of high coupling. The article then classifies coupling and explains each type of coupling along with the ways to eliminate the coupling.

Coupling

Coupling is the factor of dependency of one class on another class. The factor of coupling varies between low and high. Systems having high coupling are unstable and requires more effort to modify. In a system with high coupling factor modification in one class forces a ripple of changes in other classes and thus increases the effort required for modification. High efforts require more cost. High coupling also decreases the reusability of a class because the dependant class must be included. Classes with high coupling are difficult to understand in isolation. System having low coupling are stable and when a change is made in one class will not require change in the implementation of other classes.

Coupling is classified as follows,

Content coupling

Content coupling exists between two classes when one class relies on the internal working of another class i.e. one class is using the variables of another class. When a class holding content is modified to contain another format of the content then other class using the content should be modified. The coupling factor for content coupling is high. This form of coupling is undesirable because any class can modify the internal data of another class. To reduce use private access control for the contents in the class and provide accessing methods such as getVal and setVal.

Common coupling

Common coupling exists when classes in the system share a global data. Changing the format of the shared resource requires modifications in all the classes using the global data. To reduce common coupling create a class to contain global data and add public methods in the class to obtain or modify the global data. One should use critical sections in the class.

External coupling

External coupling is dependency of the class on third party classes like MFC, QT etc. or share an externally imposed data format, communication protocol or device interface. External coupling can be reduced by using façade pattern.

Control coupling

Control coupling is one class controls the logic of another class, by passing it information on what to do example, by passing flag or command thus, controlling the sequence of execution. To reduce use polymorphic operations or use a look up table that will map a command to a method.

Stamp coupling

Stamp coupling is a form of coupling in which two classes modify or access data in the same object. To reduce add methods to access or modify all data within the object.

Data coupling

Data coupling is the form of coupling in which one class passes simple data to another as an argument. Coupling is due to interpretation of data i.e. meaning of data that passed as argument to the member function of another class. If the meaning of the data that is passed as argument is changed then other class has to modify to accommodate the change. To reduce developers should not pass unnecessary arguments and should pass few arguments, each containing more abstract information.

Message coupling

Message coupling is the lowest possible coupling. Classes are not dependent on each other instead they use a public interface to exchange parameter-less messages (or events).

Routine call coupling

Routine call coupling is a form of coupling in which one routine calls another. To reduce the total number of routines that a particular class calls must be reduced. If there is a sequence of two or more routines to compute something and this sequence is using in more than one place then to reduce routine call coupling a single routine must be written that encapsulates the sequence.

Inclusion coupling

Inclusion coupling is a form of coupling in which one component includes source code of another component. If the included component changes something on which includer depends or adds something that raises the conflict with something in the includer then the includer must change. To reduce do not include component those are not required.

History

version 1 : Intial article without examples.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Milind Shingade



Occupation: Web Developer
Location: India India

Other popular Design and Architecture articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
  (Refresh) 
Subject  Author Date 
-- There are no messages in this forum --

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 28 Jul 2007
Editor:
Copyright 2007 by Milind Shingade
Everything else Copyright © CodeProject, 1999-2008
Web18 | Advertise on the Code Project