Recently I had an interesting conversation with a business process professional, on the subject of SOA services. I started talking about ‘white-box’ and ‘black-box’ services, assuming they were clearly understood terms. It turns out that they weren’t. Here’s how I explained the two terms, and why they’re important.
The services in your SOA need to be ‘black-box’. If ‘white-box’ services creep into your architecture sooner or later you’ll have problems because white-box services increase coupling, thus violating one of the fundamental tenets of SOA (that services should be loosely coupled).
So what’s the difference between white-box and black-box?
Everyone is familiar with airline travel so let’s use that as an example.
Let’s say you want to go on a trip to attend a sporting event.
Now there are two ways of achieving your goal of attending the sporting event.
The Black-Box Way
You find a good travel agent and you tell them “I want to go to ‘such and such’ a sporting event on this date and I want you to arrange everything I need to get me there”.
They’ll ask you to fill out a form with all the information they need to fulfil your request: dates/times, credit card details, name etc, In SOA terms this form is the ‘contract’ through which you interact with the travel agent ‘service’.
You don’t care what they do with that form, who they have to speak to or how they go about arranging everything. It could be all online in real-time or maybe the pick up the phone and make all the bookings manually with each party concerned (event ticket office, airline, airport transfer company etc). You tell them WHAT you want and leave them to it. It’s “black-box”.
The White-Box Way
You find a not-so-good travel agent. They ask you to fill out 5 forms:
- A form for booking a taxi from your house to airport through Tristate Taxis Co.
- A form for booking an airline ticket through Qantas.
- A form for booking a transfer from airport to hotel through Fred’s Airport Transfers
- A form for booking a hotel room at the Hyatt.
- A form for booking a event tickets through Ticketek
In this situation you can see inside the travel agent ‘service’. You know exactly HOW they’ll go about getting you to your sporting event. You know step-by-step what is involved and who is involved.
Why is this bad? Because the travel agent ‘service’ wont be able to change anything about its internal implementation without affecting consumers:
- What if you want to use a different airline?
- What you need a transfer from the airport straight to the event, but your luggage needs to be sent to the hotel?
Keep your SOA services black-box.
That is a simplistic example. The core concept is: consumers of services should only be concerned with WHAT your service does. Services should not leak any details of HOW they do