Loose Coupling: Dimensions and Categories
|
|
I had a very thought provoking conversation with Doug Kaye. This got me thinking about refining my thoughts about Loose Coupling.
There had been other blogs written in response to the Doug Kaye's original posting.
Loosely Coupled Frameworks enable tightly aligned business integraton provides a definition. "Loosely coupled frameworks allow individual nodes in a distributed system to change without affecting or requiring change in any other part of the system.". However, this is more like the motivation for loose coupling.
Shades of loose coupling points out correctly that loose coupling or rather coupling is a matter of degree. "Instead, there are an infinite number of degrees, ranging from not-very-tight-coupling all the way to almost-completely-decoupled.". However, I have to argue that there's not an infinite number of degrees, rather its a fixed number and many cases a small number.
Which brings me back to my original table, that table did not define loose coupling, it merely presented different incarnations of it in practice. First of all I realized that the primary reason for introducing loose coupling is to essentially manage change in a system, it is not a feature that is necessary for a system to operate, rather its a way to manage the complexity introduced by change. This makes perfect sense to me, the advancements in computer languages are really to build abstraction to manage complexity, one kind of complexity is change.
However, what exactly did I define in each row of that table? Each row appears to define a different dimension. The methodology is simple, define a dimension and then identify how to decouple the different end points of a dimension.
There appears to be 3 general categories of decoupling:
(I) Decompose a single concept into multiple components.
(II) Place an intermediary point between two interacting end points.
(III) Define things as late as possible.
| Dimension | Tight Coupling | Loose Coupling | |
| Interface | Semantics | Class and Methods | REST like (i.e. fixed verbs) |
| Messaging | Identity | Procedure Call | Document Passing |
| Typing | Semantics | Static | Dynamic |
| Synchronization | Time | Synchronous | Asynchronous |
| References | Identity | Named | Queried |
| Ontology | Semantics | Implicit | Self Describing (Reflective) |
| Schema | Syntax | Grammar Based | Pattern Based |
| Communication | Identity | Point to Point | Multicast |
| Interaction | Identity | Direct | Brokered |
| Evaluation | Time | Eager | Lazy |
Category I
Break up a procedure call into 2 components, the action and the continuation.
Schema. Systems that require complete definition of syntax of a language, that is those that require a context free grammar versus systems that require only partial definition.
Communication from one party to another consists of a sentence with a verb and a noun. First of all there needs to be an agreement on semantics. However, we can standardize on the semantics on the verb part, and therefore allow certain classes of communications to be possible without prior agreement between the parties. It may seem that its pushing the problem down to another level, however I would argue that there are certain classes of communication that do not require full knowledge of the complete sentence.
Category II
Instead of an 2 events occurring at the same time, allow them to occur at different times and have the original semantics preserved.
Instead of one party knowing the identity of another party or resource, use a query instead to discover dynamically the other party or resource. (Query or Query Broker is intermediary)
Communication. Who do you respond to, broadcasting makes the receive anonymous, point to point requires that you know the identity of the receiver. Similarly, direct interaction (same thing as point to point) requires knowledge of the other party, brokered interactions however places an intermediary in between the interactions.
Category III
Typing, an objects type is discovered only when it is needed.
Ontology. Self Describing is analogous to reflective. In other words, a system where you have access to the meta level that is the definition of objects is more adaptable to change than one that has this information only in an implicitly. Systems that have structure defined by prior agreement tend to have the definitions defined on paper, however they not necessarily be a reflective system. That is, explicit meta-level allows the discovery of definition when its needed or as late as possible.
Evaluation either Eager or Lazy, that is when in time do you perform an action, is discovered as late as possible.
In summary, there are a few dimensions that we can introduce some kind of decoupling. We have Identity, Time, Semantics and Syntax, Einstein may argue that Identity and Time are the same thing. There are however different ways to achieve decoupling, that is decomposing, introducing an intermediary (actually seems to be like decomposing an interaction) and finally delaying the binding. Loose coupling then is defined in terms of dimension and the how the decoupling is acheived.

