World Wide Webber


My Books
REST in Practice: Hypermedia and Systems Architecture
Now available on Rough Cuts
Developing Enterprise Web Services by Sandeep Chatterjee and Jim Webber
Amazon:
US, UK, Canada, Germany, France
Now available: Korean Edition

My Bookshelf
Programming Clojure by Stuart Halloway

RESTful Web Services by Leonard Richardson and Sam Ruby
Anemic Service Model
Posted: 19 April 2008 @ 00:47 UT from Calgary, Canada
Last updated: 21 April 2008 @ 15:50 UT

Much of contemporary SOA thinking is centered around the notion of very loose coupling. So thinking goes, tight coupling leads to nasty brittle enterprise systems which resist change and over time become a costly legacy. Conversely loose coupling allows individual systems (applications, databases, etc) to be evolved much more readily.

Slide1

And to be fair, this seems like a sensible notion - if our systems are decoupled from each other then localised changes should be a breeze. Indeed most of the SOA bookshelf currently blighting your local bookstore carefully build towards to the notion of loose coupling of systems as the default and desirable state of an enterprise system.

I beg to differ. (But you might have expected that if you follow this blog.)

You see, back in the day, I attended a class or two at university and had the good fortune to be taught elementary software engineering by Prof Pete Lee (who was, despite my best attempts to get thrown off my undergraduate course through general laziness and ineptitude, later to become my Ph.D. supervisor). Now Pete is an old hand at this software stuff and he duly taught us that loose coupling is one of the keys to good software design and by extension good enterprise systems. But Pete didn't get caught up solely in loose coupling because he was sensible enough to see it as just one of the axes against which good software design can be measured. A further key metric, much forgotten about in the rush for loose coupling, is cohesion, which can be usefully defined as the "measure of the extent to which related aspects of a system are kept together in the same module, and unrelated aspects are kept out."

In fact good software tends to be both loosely coupled and highly cohesive which is really easy to visualise:

graph

As the graph shows, software which is both loosely coupled and highly cohesive tends to be good. Software which is neither loosely coupled nor cohesive is superbad, and I really mean superbad (don't click if you're at work or easily offended) in most sincere sense - it's so gross, messed up, and adolescent it's actually funny.

Which brings us to the merely bad software - including all that loosely coupled stuff.

Some software is highly cohesive in design, but tightly coupled. This means though it may be logically laid out, it's tough to change because of tight interdependencies. That's pretty bad, and unfortunately also common for enterprise applications. Remember that software which really wowed you a few years ago but is much more of a pain to maintain than you'd like? That's because it's tightly coupled.

The other kind of bad software is loosely coupled but lacks cohesion. That means that there are few explicit interdependencies between modules, but none of the modules are necessarily authoritative about any particular aspect of the system. This in turn results in a scattergun approach to ongoing system evolution as even minor changes ripple through multiple components or systems. Or SOA as we have come to know it nowadays.

Now have a look back at the first diagram where we have our wonderfully loosely coupled SOA. Go on, have a good old stare at it.

On the one hand we're inclined, and indeed encouraged by the SOA brigade, to think of this architecture as a good fit for purpose because it is very loosely coupled. Since every component or service is decoupled from every other component or service it should be possible to arrange and re-arrange them in a Lego-style in a myriad of useful ways. Building out "business services" from some more fundamental set of services is how the books tell us to do it. In fact we could even do that quite easily with point-and-client BPM tools, ruling out such overheads as developers and change management along the way. Right?

No. In fact absolutely wrong. It falls victim to the what I'll call theĀ  Ford-Lucas paradox[*]: while you can write books about it, this is an architectural fantasy that has no place in real world enterprise systems. In fact a service that does not address a business problem has no right being in an SOA (and yes, security is a business problem so there!).

Take a look at the SOA diagram again and try to pick out where there is high cohesion between the services and databases. Even though it's a low resolution diagram, it's obvious that there isn't much about SOA du-jour that encourages cohesion - in fact low cohesion is a by-product of this architecture to keep those services and databases general enough to be recomposed by the BPM toolkit. And we all know how successful that is: Not very.

But there is a more sensible way to SOA, which maintains loose coupling and drives high cohesion and the secret is this: build your services to implement business processes. Don't let the data guys scream at you that you need an enterprise data model (you don't) and don't let the application portfolio guys demand that you buy everything and stitch it together later (you can't, this only gets you Frankenstein systems). Instead talk to the business guys and understand their processes, their workflows. Help them to prioritise which of those processes or workflows are most important, and then build out a service that implements that process. Don't forget to include the business-centric messaging (if you're SOAP-y) or resources (if you're Web-y) that the process uses to enable it to be consumed by other processes across the enterprise (or even more widely).

If you're confused about how to build such a service, it's just an instance of MVC:

ServiceArchitecture

Now find the next highest priority business process and do the same again, and again, incrementally driving out your enterprise architecture and tying back each part of that architecture to a crisply defined business requirement. You'll start to drive out a set of services which can be pinned back to business processes, which leads to a scenario where process composition and service composition are one and the same.

CollaboratingServices

At this point now doubt I have irked a few people who would love to thrown in a couple of "governance grenades" about how this kind of loosely-coupled/highly-cohesive architecture is hard for architects to govern. And you know what? I agree wholeheartedly. Well, sort of.

An SOA isn't for governing by architects, not if it's done right. Sure I expect my architects to guide teams towards making excellent technology choices as part of service delivery. I also expect that my enterprise architects have a duty of care to the long lifespan of the enterprise over and above any one system or service. But this isn't where I want to govern my SOA, in fact I don't want to govern it at all: I want my business stakeholders to do that, because they own those business processes that I host in my services. In effect they own the services.

It might sound like a pretty dumb idea that my business stakeholders are to become (inadvertent) IT architects. After all these are generally people whose knowledge of complex IT systems barely extends past "turning it off, then turning it on again." Yet in reality they are the authoritative source of truth for business processes - those same processes that we reflect in our services. So when a process changes or is retired in the business world, the business folks (inadvertently) govern the SOA world - we change our services to continually match the business-level processes.

And all of this is possible because we thought about cohesion, not just loose coupling. Now just imagine if we used all those other metrics too...

[*] I coined this term from the crew's banter in the production of the original Star Wars film where Harrison Ford said to George Lucas, "You can type this shit, George, but you sure can't say it." It is amazing how often enterprise architects, SOA authors, and middleware vendors play the George Lucas role leaving delivery teams to pick up the slack and belt out a jolly good Han Solo anyway.

Update:Steve Vinoski's written about this too, although as usual somewhat ahead of me!

Comments:
#

Hey Jim, 

Just wondering if you think there's any relation to granularity, which is something often talked about in SOA-world (i.e., "coarse-grained, loosely-coupled").

#

Hi Mark. You may want to take a look at articles such as http://www.objectmentor.com/resources/articles/granularity.pdf, http://www3.interscience.wiley.com/cgi-bin/abstract/113446666/ABSTRACT?CRETRY=1&SRETRY=0, http://www.cs.nuim.ie/research/pop/papers/AineMitchellPhD.pdf, http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=991462 and http://www.cs.auckland.ac.nz/~hayden/research.htm. Some of them are a bit old, but the general notion that we get from software engineering hasn't changed much over the past 2+ decades. If you want any more references (books as well), drop me an email.

#

Hey Mark (Nottingham in this case), 

Actually I think granularity is easy (though I confess reaching that zen state has been hard). The granularity of the messages (or resource representations if you like) are governed by the business processes that your service supports. 

If your business process is really fine-grained then you may (or may not) have an opportunity to re-engineer and optimise that process. If the process is naturally fine-grained then your service will be too - it just makes it a bit harder to ensure that your service is efficient. 

Although it might sound a bit newspeak, I prefer the term "right-grained" because the granularity of the service interactions is set by the right-grainedness of the business process interactions. 

So onto Mark Little's pointers: yes these things are very valid in CS terms, but in business systems CS plays a supporting role. It would be great if our processes were really coarsely grained, but if not we'll just have to deal with any engineering issues that might arise. 

Hope that makes some sense... 

Jim

#

If you coin "right grained" then it has to go hand-in-hand with "right coupled" then ;-)

#

Hey Mark (Little), 

Hmmm you could be right, but I suspect that statistically right-coupled _is_ loosely coupled by default - because business processes tend to be quite decoupled too (payroll knows nothing about asset management's processes). 

Jim

#

"I suspect that statistically right-coupled _is_ loosely coupled by default" 

You're assuming that "right coupled" implies loose coupling in all domains. But it doesn't. There are degrees.

#

Hi Mark (Little), 

Yes I agree - that's why I let the business processes drive it out. I think coupling in an SOA context is not only the concern of IT, but also of those people on the business side who actually own those processes. 

Jim

#

Hi Jim, 

I'm not sure "business processes" are the best way to design services (this was BEA's favorite approach for years, and I strongly advocated it in my years there). Even IBM advocates this approach with SOMA. 

The problem is that it leads to a couple of quasi-political and architectural problems: 

- the way in which you design your business processes reflects the sponsor of the project, which often is not aligned to the stated goals of the organization (such as "customer centricity") 

- It can tend towards a very functional-decomposition design mindset, wherein activities & tasks become services, the process itself becomes a service, and... there's no real interoperability once you cross organization boundaries that have developed different but over lapping processes. 

- Some services serve business needs but don't actually "belong" to any particular business process, they're used across several pre-defined processes, but also in an ad hoc way to facilitate knowledge work.  

These are "data services" that include content repositories, data warehouses, Wikipedia (and other social/community mediums on the Web), etc. And these sometimes need to feed systems, not just humans.  

Generally, I've one major driver towards SOA was to provide the architecture and governance to support these sort of "autonomous" services that have traditionally been duplicated across business units. "Customer" is a good example, though sometimes "Order management" and "Product management" is another. One could think of these as business processes of a sort, though they often become tacit as the organization grows in size, since every department or org unit has a different understanding and policy of what those terms mean. 

There's also a data quality dimension to such services. For example, one can't reasonably expect good visibility on one's customers without a "Customer" service of some sort. 

You claim above that you don't need an enterprise data model. Well, I suppose you don't in the context of "a" project, but that's not exactly going to lead to easy interoperability across projects, or for cross-process data services.  

I would never claim the need for a huge up-front investment in an enterprise model. And I don't claim that there's such a thing as *one* enterprise model. But service operation & data interoperability is the very problem that the nascent SOAs of the world, especially large ones, are struggling with. We have independent piles of functions and data structures and no clear way to mix them productively without introducing vendor-ware like ESBs. 

Anyway, just some random thoughts on what was otherwise a great post. To second Mark Little, I've often found Robert Martin's principles of OO are just as applicable to SOA as they were to C++. ;-)

#

Hi Jim, 

Good post. I think you'll find the current Amazon Platform exemplifies a fair amount of what you have said, although they did not architect their platform for loose coupling, cohesion, based on business processes from the outset. See http://www.infoq.com/presentations/vogels-amazon-platform - *very* interesting presentation on the development of the platform from a simple client-server platform, to what we see in AWS today.  

Vogels sees each AWS as a startup company, giving developers complete ownership of service's lifecycle, achieving interoperable loose coupling (design by contract) in a cohesive manner (combining services that participate in very large business processes - see above video for examples). Obviously, Amazon has gone further by exposing many of these services and tying in business models with reasonable payment terms (S3, EC2, SimpleDB, SQS). This now means external organisations can compose their SOI that reflects their business processes using highly reliable (Amazon claims one data centre can collapse and the SLA will still be enforced) services they don't even own. Doesn't take long to see the numerous value chains that could come out of this. 

Stu's concerns about operation and data interoperability between inter-enterprise services could be a concern, but can easily be mitigated with contracts (as Amazon have done), and lots of metadata (WS-[Security]Policy, etc.). The OGC is a good example of a standards body that has put a lot of effort in defining web service interfaces for primitive services - Web Processing Service (general purpose job submission), Web Feature Service (general purpose database, and GML for its data model (ridiculously large, but geospacial data can be verbose!). Lack of a data contract can lead to the erroneous use of XMLElement (consider the comedy that is WS-Trust RST) to communicate any data model. Lack of a service contract could lead us down the path to the completely unambiguous invoke(XMLElement), submitted to OASIS as WS-Nothing. 

Other concerns might be how to federate identity between organisations (how does an engineering company use Nastran, PAM-Crash, etc. supplied by different companies in a workflow, using existing *internal* identity infrastructures?), and how providers of such services charge for usage against an SLA. Amazon's SLA is a start, but really needs a variety of SLAs based on the needs of customers (bi-directional, think NextGrid model). 

Your thoughts on governance I think are spot on. Acknowledging and using the expertise of stakeholders not only increases the probability of acceptance of the overall infrastructure, i.e. it follows their view of business processes, it also gives them an appreciation of capabilities of the infrastructure - this can lead them to develop novel value chains and business models, thus make more money. 

Cheers, 

Rowland

#

Hi Rowland, 

It's good to hear that I'm at least following in the path of a very successful engineering approach like Amazon. It happens to be working pretty well at my current client too. 

I couldn't agree more about the weak metadata that's floating around out there, but then there's always SSDL (http://ssdl.org)... 

Jim

#

Cohesion is an intra-module concern. SOA is about managing inter-module concerns.  

http://www.manageability.org/blog/stuff/soa-rediscovering-modularity

Author Name:
Email:
Author URL:
Comment:
Antispam:
Please type the following string (note that if the strings don't match, your comment will be lost... sorry!): 'GOTYT'.
 
Recent entries

Recent comments

Feeds:
RSS 2.0 Atom