CSC/ECE 517 Summer 2008/wiki3 3 lc: Difference between revisions
No edit summary |
|||
Line 1: | Line 1: | ||
=Low Coupling= | =Low Coupling= | ||
This document seeks to explain low coupling including when it should be used, when it should not be used, and how exactly you may make use of this technique in your own programs. | |||
==Problem Description== | ==Problem Description== | ||
We introduced the idea of low coupling in Lecture 20, and used the Observer pattern as an example in Lecture 23. But we've really only scratched the surface on what there is to know about achieving low coupling. Browse the Web and the ACM DL for other information, both theoretical and practical, and produce a guide to what there is to know about low coupling. Be sure to highlight those aspects that would be appropriate for inclusion in CSC/ECE 517. | We introduced the idea of low coupling in Lecture 20, and used the Observer pattern as an example in Lecture 23. But we've really only scratched the surface on what there is to know about achieving low coupling. Browse the Web and the ACM DL for other information, both theoretical and practical, and produce a guide to what there is to know about low coupling. Be sure to highlight those aspects that would be appropriate for inclusion in CSC/ECE 517. | ||
== | ==Coupling== | ||
[[Image:dependency.jpg|thumb|right|150px|Dependency]] | [[Image:dependency.jpg|thumb|right|150px|Dependency]] | ||
Coupling, also known as dependence, is a measurement of the degree in which two program modules rely on each other to complete a task. | Coupling, also known as dependence, is a measurement of the degree in which two program modules rely on each other to complete a task. Coupling can be examined at the class level by examining individual interfaces between classes or at a higher level by examining a group of dependencies between multiple classes in a program. | ||
Recognizing dependencies: | Recognizing dependencies: | ||
Line 13: | Line 14: | ||
*As seen to the right in UML diagrams a dashed line with an open arrow points to a dependent class. | *As seen to the right in UML diagrams a dashed line with an open arrow points to a dependent class. | ||
When these two modules have a very stable interface between one another, one which does not require or even concern itself with the internal structure of the other module, you have "low" coupling. Other terms used to describe this situation may be "loose" or "weak" coupling | When these two modules have a very stable interface between one another, one which does not require or even concern itself with the internal structure of the other module, you have "low" coupling. Other terms used to describe this situation may be "loose" or "weak" coupling. | ||
==Postive Features== | ==Postive Features== |
Revision as of 13:53, 31 July 2008
Low Coupling
This document seeks to explain low coupling including when it should be used, when it should not be used, and how exactly you may make use of this technique in your own programs.
Problem Description
We introduced the idea of low coupling in Lecture 20, and used the Observer pattern as an example in Lecture 23. But we've really only scratched the surface on what there is to know about achieving low coupling. Browse the Web and the ACM DL for other information, both theoretical and practical, and produce a guide to what there is to know about low coupling. Be sure to highlight those aspects that would be appropriate for inclusion in CSC/ECE 517.
Coupling
Coupling, also known as dependence, is a measurement of the degree in which two program modules rely on each other to complete a task. Coupling can be examined at the class level by examining individual interfaces between classes or at a higher level by examining a group of dependencies between multiple classes in a program.
Recognizing dependencies:
- A member function of class A uses an object from class B.
- When making CRC cards the "collaborators" column denotes classes which depend on one another.
- As seen to the right in UML diagrams a dashed line with an open arrow points to a dependent class.
When these two modules have a very stable interface between one another, one which does not require or even concern itself with the internal structure of the other module, you have "low" coupling. Other terms used to describe this situation may be "loose" or "weak" coupling.
Postive Features
Ease of Modification
When a module is modified in a well-structured system, one which makes use of low couping, very few subsequent modules must be modified as a result. While this has obvious benefits in reguards to the speed at which changes may be implemented and the limited testing that must be performed as a result.
Information Hiding
Anytime you can hide the design details of your program so that other modules and services may utilize a standard rarely changing interface your program will be less likely to break other modules as a result of design detail modifications.
This is essential to coding a well-structured system which may grow and change to the users requests or external requirements beyond the programmers control. In the every changing workplace as soon as a program has been coding and fully tested, it seems that modifications are needed or often required.
Negative Consequences
Reduced Performance
One of the unavoidable consequences of low coupling is reduced performance in most situations. Usually however reduced performance is highly tolerable when compared to the increased programming efficiency and future modification.