Sign in to follow this  


Recommended Posts

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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this