If you ever stayed in cheap hotel, you will see hair drier directly attached into the wall outlet.

Tight coupling

Now couple of problems here.

  • What if your hair drier stopped working?
  • What if hotel management decided to switch to new model which consumes less power?

To fix the hardwired hair dryer, they will have to cut the power to the room, rendering it temporarily useless. Then, the technician will use special tools to painstakingly disconnect the hair dryer and replace it with a new one.
The solution to above problem is to introduce a socket. Something similar to below diagram

Loose coupling

This kind of problem exists everywhere, even in software industry.  Most of the times engineer write’s tightly coupled code without understanding the consequences. If two components are tightly coupled, then change on one component requires huge effort; similar to hair drier problem. There is always a possibility of breaking other component.

So how do we solve it? Always attempt to write loose coupled code where two components are attached with each other using interfaces (socket – in case of hair dryer problem)

Share Button

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation