Services and the real meaning of coupling

Java Development News:

Services and the real meaning of coupling

By Johannes Brodwall

22 Aug 2006 |

What happens when a customer asks for a simple new bit of functionality? Do you have to execute changes on four different systems, test each in isolation and in combination, involve a separate testing, infrastructure and operations team?

If so, your architecture is probably not service oriented. In this post, I will examine the real meaning of coupling, and how it relates to SOA.

I will, like others talking about SOA, try to define what I mean by SOA in this post. I will do this by talking about what SOA is not.

Component Based Design: First: SOA is not the same as Component Based Design. Services in a SOA architecture are distributed. Components in component based design are (usually binary) pieces of code that are packaged with each system they are used in. In this sense, EJBs can, and are, used both as services and components.

Component based reuse is often simpler than service based reuse. With service based reuse, the impact of a change in the reused component is much less tractable. There might be systems using my service that I'm not aware of. With components, this may also be the case, but each system has to make a conscious decision to upgrade the component, so any accidental breakage in a system can be related back to a change in that system.

Business Oriented: More than being distributed, I think SOA Services are intended to be business oriented. That means that the reason to change a service should almost always be a change in a business requirement for that service. Specifically, if a service has to change because of a new business requirement in another service, I lose.

Coupling: This is the real meaning of "coupling:" Two systems are tightly coupled if change to one of the systems is likely to require change to the other system. This is a metric that is hard to measure by looking at the code, yet many believe that code metrics can be used to understand coupling.

And this is where non-SOA distribution really hurts: Implicit coupling. If I make two parts of my system remotely distributed, they are deploy-time decoupled. But if I have to upgrade both parts at the same time, this decoupling hurts more than it helps. If I pass data as Strings between two parts, so "we can support any changes to the XML schema in the future," these parts are compile-time decoupled. But if I have to upgrade both parts at the same time, this decoupling hurts - it doesn't help. The reason is that the coupling is still there - it's just implicit. I want to call this approach "Using code metrics to shoot yourself in the foot."

If my service network is well designed, my services will really be loosely coupled: Changes to one service is not likely to impact other services. However, achieving this design goal is hard. And if I do it wrong, it hurts me.

In conclusion: If you can identify and extract services that really are loosely coupled, SOA may very well work for you. For parts that are tightly coupled, you can still achieve benefits of reuse, but you are better off doing so through component based design.

About the author

Johannes Brodwall  

Johannes Brodwall has been playing around with computers for as long as he can remember, and was obsessively fascinated by dot matrix printers at the age of six. He has been working as a programmer and software architect since 1998. Johannes is currently lead Java architect at BBS, the company that operates Norway's banking infrastructure. At BBS, he helps select Java technologies and train developers in these technologies. In his spare time, Johannes likes to learn esoteric languages like Ruby and Modern Standard Arabic. He lives in Oslo, Norway, with his wife Sarah and bulldog Ada Mae.