SOA

I’ll be giving a ThoughtWorks Quarterly Technology Briefing in London and Manchester in a few weeks time, titled Business Architecture Foundations of IT.

I used to introduce this topic with a quote from Beckett’s Unnameable – “You must go on, I can’t go on, I’ll go on” – which nicely sums up the situation I see many organisations facing today: burdened with a legacy systems estate, unable to stop the world, sorely in need of a change in strategy to face the future.

Based on case study material from the last few years, talk suggests some future proofing strategies that can arise out of an assessment of today’s business operations.

I’ve many times worked with developers and architects to help them understand the nature and implications of their distributed systems design choices. One of the ways I’ve found of framing a useful discussion is to look at coupling issues – particularly those arising as a result of temporal and behavioural coupling.

Every apostate technician on his or her descent to whiteboard irrelevancy ought produce at least one “magic quadrant” diagram. This is mine: the coupling matrix. Whilst sadly not a career-making architectural silver bullet, this diagram may help you characterize the several parts of your extant solutions, envision direction for future initiatives, and understand the constraints – both legitimate and inadvertent – that in part determine the design options available to you.

First, a brief overview of these two types of coupling:

Temporal coupling

Temporal coupling refers to the degree to which the sending and handling of a message are connected in time. If a sender is dependent on a receiver being available when a message is sent, we have high temporal coupling: if the provider is not available, the interaction fails. Processes whose activities are strictly ordered or whose results carry forward, leaving subsequent activities unable to start until a response to a prior request has been received, are similarly temporally coupled. In situations of high temporal coupling, the time taken to handle the message and return a response increases the processing time on the sender side.

Behavioral coupling

Behavioral coupling refers to the degree to which parties share assumptions regarding behaviors, more specifically, to the implications of assigning the twin responsibilities for determining what action to execute and how to execute that action to the parties in a distributed interaction. In systems that exhibit an extremely high degree of behavioral coupling, the sender of a message determines what to do, and also knows something of how the receiver ought satisfy its request. Such coupling is typically evinced by, for example, database foreign keys and/or platform-dependent artifacts such as collection types leaking into messages and operations. If a sender determines what to do, and a receiver determines how to satisfy the sender’s request, the participants similarly exhibit a high degree of behavioral coupling. If a receiver alone determines both what to do and how to do it in reaction to a received message, the sender and receiver have low behavioral coupling. High behavioral coupling requires a provider to evolve its service offerings in response to changed consumer requirements.

And then some sketchy characterizations of each of the quadrants:

Distributed 3-layer

Traditional 3-layer application architecture blown up to distributed proportions. Characterized by call stack-like, imperative behaviour (high temporal and behavioural coupling) and synchronous request-response interactions. Includes systems that layer synchronous interactions on top of asynchronous message exchanges. Senders tell receivers what to do; receivers execute the sender’s orders. Sender and all intermediaries block until the call stack unwinds, effectively locking and/or consuming system resources further up the call chain. This blocking behaviour undermines the autonomy of upstream components and at the same time increases the availability requirements of downstream components. As Michael Nygard’s Release It! reminds us, in these circumstances the availability of the overall system can be no more than that of the least available participant, and the probability of failure is the joint probability of failure in any component or service.

Command-oriented

“Good”, “orthodox” SOA. Low degree of temporal coupling characterised by asynchronous interactions, deferred state and a resumable programming model (process or activity instances are dehydrated between remote invocations in order to conserve resources, and then rehydrated based on correlated responses). Senders typically determine what needs to be done, but rely on receivers to determine how to execute their instructions. This behavioural coupling can require providers to evolve (message formats, supported operations) in lockstep with changing consumer demands.

Event-oriented

Low temporal and behavioural coupling. Receivers determine both what needs to be done and how to do it based on the content of received messages. Resumable programming model: processes are suspended or dehydrated, waiting for events. Can be difficult to trace the execution path of an end-to-end transaction or activity. Exposing an ExtinguishFire operation is a command-oriented way of executing a business process; acting on FireStarted notifications an event-oriented approach.

Emergency services

So called because you tell them what happened, and they decide what to do, but if there’s no one to take your call, you’re hosed. Low behavioural coupling, which allows for the independent evolution of system components, but a degree of temporal coupling, impacting availability requirements of participants. Many RESTful solutions occupy this quadrant. URI-templated solutions have a higher degree of behavioural coupling than hypermedia-driven solutions (where servers constrain and guide what a client can do next, and determine how best to satisfy requests); client polling and caching can mitigate some of these temporal coupling issues.

Endnote

These coupling issues are well understood by many developers and architects – to the extent they comprise a general base of knowledge without specific authority or provenance. I would, however, like to draw your attention to one of very many excellent posts by Bill Poole, Avoid Command Messages, that some time ago helped bring behavioural coupling into focus for me.

Some commentary from Richard Veryard on a conversation between Udi Dahan and Colin Jack over business capability modeling caught my eye yesterday. I wanted to write something in support of Richard’s comments, and at the same time illustrate a practical approach that helps “identify capabilities with … high cohesion and low coupling” and “draw a matrix of the interactions between entities and processes”.

Over the course of a piece of analysis some things, some entities, will emerge as being of particular significance to the business. Customer and order, for example. Don’t refuse to acknowledge or model these things, but don’t get hung up on them either: they’re just a part of a whole that includes not only concept models, but lifecycle models and capability maps.

Take customer for example. We can, very quickly, create a high-level picture of what a customer might look like – an overarching, company-wide view of all the parts of a customer that are of interest to the business, or the several parts of the business. But this isn’t the domain model: rather it’s an approximation, a temporary stabilizing of multiple shifting perspectives, a flawed starting point – just good enough – for further investigation.

Side-by-side with this high-level conceptual view of a customer, we can also model the customer lifecycle; that is, the story of a customer’s relationship with our company. I’ll often model this in the form of a state machine. We then see that our interest in a customer can be expressed in terms of our transitioning the customer through several different states.

For each transition in this state machine, we can now ask: what business capabilities do we need in order to transition the customer from, eg. lead to applicant? How well do we implement these capabilities today? And so on.

Capabilities operate on the customer in order to transition it through different states, in so doing releasing value both to the customer and the business.

What likely starts to emerge are business-meaningful bounded contexts, each context encapsulating part of the high-level picture, plus one or more state transitions, plus the capabilities necessary to effect those transitions. Each bounded context projects a different view of the customer onto the business landscape – suggesting there’s not necessarily an organization-wide canonical model of a customer, just many “interested” views. That’s why I say our original high-level picture isn’t the domain model: it’s simply a starting point for identifying the bounded contexts – and the processes – that transition the overarching concept “customer” through states in the customer lifecycle.

What we end up with is a high-level model/picture divided by bounded contexts, a customer lifecycle model, and a capability map. Together these comprise part of an operating model – a useful representation of the organization that we can use to identify desirable business outcomes and guide the identification, planning and prioritization of projects.