Wednesday, May 30, 2007

Loose coupling/tight coupling: When things go wrong

I was thinking about coupling this morning. Loose coupling allows for one part of a system to change without impacting other parts of the system. The other parts are shielded from the impact because the coupling point is a contract. As long as the change happens behind the coupling point and the contract is fulfilled correctly, a change in any particular module will not affect any other module that relies on it.

But that's not really what I was thinking about this morning. I'm thinking more about trains, and the Tokyo train system specifically.

Every morning I take the Tozai line from Minami-Gyotoku to Nihonbashi. The "東西" line is one of the few train lines that, as its name suggests, travels the entire distance of Tokyo from East to West.

Before I get too far ahead of myself, I have to explain a little about the train system in Tokyo. There isn't just one train company here. There is the well-known JR lines (pdf) which has the famous Yamanote line which circles the heart of Tokyo and connects at many stations with other lines. There is also the very popular Tokyo Metro (pdf) of which the Tozai line is one (the blue line running from east to west). Still relevant and convenient is the Toei Transportation system which runs several trains (see the Tokyo Metro map) and a host of buses around the city. Less well-known lines like the Tobu lines and the Odakyu lines are also here.

What brought on this thinking of coupling wasn't the coupling of trains, but the coupling of train lines. If you look at the various maps, you will see that many train lines intersect with each other. These are prime points for coupling, and indeed many of those intersections are coupled by means of a shared station.

By "loose coupling" here, I mean that the passengers must unboard one train and reboard another to make the transfer. This is very convenient, though sometimes the rush to change trains is overwhelming with so many people needing to transfer at the same station. Also, it requires that the passengers actually leave one train to change direction. This is the standard way this works, and it works well.

But there are other points in the system that are much more tightly coupled. This means that more than just sharing stations with each other, multiple train lines may actually share the same track. The Tozai line is a prime example of this with its endpoint on the western end shared with the JR Sobu and Chuo lines. The Sobu and Chuo lines themselves share tracks from JR Ochanomizu westward. If you take a close look at the train maps, you'll even notice that the Tozai line and the Sobu line are connected at their endpoints and diverge in the middle, providing a wider area of service with the same terminal stations.

The benefit to the passenger should be obvious. By being able to board a single train and not have to transfer at stations, the passenger can relax and not be bothered until he reaches his station. From the passenger's point of view, it is less hassle and potentially faster than a series of transfers which loosely coupled train lines would require.

The downside, as I encountered this morning, is that a system failure in a shared area leads to a total system failure across all coupled systems. I get on the train at Minami-Gyotoku, as I mentioned before. It is on the east end of the Tozai line. An accident on the Chuo line, far on the west end of the lines, caused backups all the way through the entire Tozai line. As a result, I was late to work.

In a loosely coupled system, I would not have been inconvenienced since the Chuo line is really of no consequence to me personally. Passengers of that line would naturally have problems, but the other lines would run normally (as the Ginza line did when I transferred at Nihonbashi). Loose coupling would have prevented the impact of an event that occurred far away from affecting me.

But we don't live in a loosely-coupled world. In fact, the world which we live in is highly coupled. Tight coupling adds convenience while potentially compromising the stability of the system as a whole. How many people benefit from the tightly coupled train systems? How many people were harmed by events like today's backups? Where do you draw the line and say "Common convenience with occasional outages outweighs minor inconvenience with guaranteed service"?