Editorials

Decoupling, Is it Worth It?

Loose Coupling, Late Binding, Dependency Injection, along with other software development techniques are all methods intended to make your code more future proof. Why should you care? It makes writing software more complicated, even with the available set of tools and frameworks. So, why should I put myself through the pain?

This is an excellent question young grasshopper (revert back to the old USA tv series, Kung Foo). I really want to know because there are so few times where something we have written is replaced with a newer or different technology.

One of the things that often happens is that we define some piece of software that is really good, and it becomes very popular. Other people see your new widget, and want to take advantage of it also. Now that they are using your new widget they are really happy and their product, which has a different release schedule, depends on how it is defined today. You need to modify your widget to do some new thing, and you have added new code. You didn’t modify existing code, because you follow the good process of Open/Closed (see the O in SOLID), but you have changes you need to push out. They have also modify the code, but their changes are not ready to go at the same time. Now you have built a dependency where you can’t release your changes until they are ready to release theirs.

Sure, there are a number of Version Control strategies you could use to work around this conundrum. And you probably should be using them. But you didn’t, and now the blocking changes are in your source tree.

This is a good example where some form of decoupling would solve this problem. Here’s a montra you should consider when working with Object Oriented tools that will help solve this kind of problem. Declare Interfaces; Implement Objects. It’s an old saying that still applies today.

It’s simple enough to decouple your software once you have learned how. So, for this scenario, and many others like it, the extra effort pays off more frequently than not

Why not share one of your experiences where you wish your software were more decoupled, or where you were glad you had decoupled your software. Drop a comment online, or send me an email to btaylor@sswug.com.

Cheers,

Ben