LOOSE COUPLNG?

Started by
1 comment, last by Verg 18 years, 9 months ago
i am looking for an extensive tutorial about loose coupling.(Example+ Explaining)...does anyone has any idea? where can i find it? (using C++ )
Essegin Ziki:) bunu bu sitede imza hesabına yazsam kimse anlamaz!!!:)
Advertisement
Quote:Original post by tonymontana
i am looking for an extensive tutorial about loose coupling.(Example+ Explaining)...does anyone has any idea? where can i find it? (using C++ )


I don't think you're likely to find an "extensive" tutorial about loose coupling as it's not a very difficult topic. Coupling, also known as dependency, refers to the degree in which components depend on each another. A coupling is creating when one component uses or accesses another. A low coupling means that one module does not have to be concerned with the implementation of another module and interacts with a stable interface rather than direct manipulation. On the other hand a high coupling is created when one module must have significant knowledge of another modules internals in order to access or use it.



Example of tight vs. loose coupling:


In C it's not uncommon for explicit data structures to be used for dealing with linked lists. Typically each node in the list will have a pointer to the previous node in the list, a pointer to the next node in the list, and a pointer to the data the node is responsible for. Any time the elements of those data structures are directly accessed either to manipulate the nodes position in the list or access the data pointed to by the node a tight coupling is created. The coupling is considered tight because if any of those data members change (either in name, definition, or responsibility) all existing code that uses those data members is now broken.


In contrast the use of the STL's list class in C++ would be considered a loose coupling. In the STL list class the methods for adding, removing, and accessing list elements is well defined. You can perform all operations for list management as well as iterate over all elements in the list without being concerned with the actual implementation. Even if the implementation were to change drastically existing code that uses the lists would not need to be changed.
Design Patterns Explained by Alan Shalloway explains design very well, before going into the topic of patterns.

Coupling/cohesion are covered thoroughly; the groundwork laid in the early couple of chapters should help you get your head around coupling, as well as many other design topics. Excellent book; not just about design patterns, either.
my_life:          nop          jmp my_life
[ Keep track of your TDD cycle using "The Death Star" ] [ Verge Video Editor Support Forums ] [ Principles of Verg-o-nomics ] [ "t00t-orials" ]

This topic is closed to new replies.

Advertisement