Tightly Coupled vs. Loosely Coupled

Posted by james on Oct. 10, 2012

Intuitively, you'd think that tightly coupled systems would be better. More integration, more sensible overall layout, everything plays nicely with everything else.

Maybe if each individual piece were perfect, that would be true. However, most of the time any given piece of software you're using has quirks, bugs, and limitations. That means sooner or later, you're going to have to deal with the non-perfect nature of a given piece of code.

A couple things that loosely-coupled software have - well defined interfaces & good separation. If you have no control or visibility into the internals of another piece of code, then you have to rely very strongly on the interfaces, and keep all your own code very separate. That means that between these two complicated pieces of code, there are a limited & well-defined amount of interactions that can happen. That helps a ton with debugging.

I'm sure if a tightly coupled system was made well, and behaved properly, that would be a great system to work within. However, given the choice between tightly coupled or loosely coupled software, loose wins.

Microsoft software (specifically ASP.NET) is a good example of this. When something goes wrong, it touches so many different behind-the-scenes pieces of software that it's incredibly daunting to even understand what's going on, let alone debug the very subtle & rare situations that trigger a given bug.

The web-development world is a good example of loosely-coupled software. You can nearly mix & match any of the given technologies at will - flash, JSON, javascript (both client & server side), web protocols, etc. And they all interoperate, and are nearly the most cross-platform/browser/machine/device software in existence today. I'd venture to guess the web wouldn't be what it was had there been more tightly coupled software driving it.

That's not to say tight-coupling doesn't have it's uses. Just that it's quite a liability, and more often than not tends to backfire.