Reality-Loop

SOA vs. DRY

February 28, 2013 | 1 Minute Read
This post was originally posted on my old blog.

In his presentation "Designing For Rapid Release" (slides) Sam Newman points out an ugly fact that we often try to ignore: SOA and DRY are to a large extent opposed forces.

Of course this is not a new break-through discovery and I guess it is also nothing new for most battle-proven enterprise developers. But I also have the experience that in most SOA projects this topic is treated like the crazy uncle in the attic: You don't talk about it and you certainly don't plan for it.

The result is usually a schizophrenic feeling: The architecture postulates nice decoupling, but in reality we end up with the feeling that we are not doing it right: either we are using shared logic in several services which negates idea of decoupling or we have a lot of code duplication.

In the presentation Sam illustrated this conflict with two services that share a common domain model:

Screen Shot 2013 02 17 at 4 53 06 PM

In the above picture, since service A and service B are both using a common model from a shared library, they get tightly coupled. On the other hand managing the development and releases of the shared library all of a sudden gets much more complicated under the premise that service A and service B should be decoupled.

He further brings the incompatibility of SOA and DRY to the point with the following quote:

Ending up with tightly bound services because of code-reuse is significantly worse than to copy & paste that code.

I like that Sam makes the conflict between SOA and DRY explicit. Not ignoring this fact is the first step to objectively balance the tradeoffs and to honestly plan how to deal with the drawbacks of either approach.