Recently, several people in the web services circles have stated that, "synchronicity affects coupling". More specifically, the belief is that synchronous behavior creates a more tightly coupled scenario. Some refer to this concept as, "coupled in time". My belief is that, "time coupling" doesn't exist.
I believe that coupling deals with one participants desire to leverage pre-existing knowledge about another participant’s internals. For example, two services are tightly coupled if one service makes assumptions about another services data or logic that are not obtainable from the interface. Thus, service encapsulation is violated and the two services become more tightly coupled.
One of the coolest things about services is that they can be piped into an intermediary (another service) on the way to the destination. These intermediaries can do neat things like:
- switch the characters from ASCII to EBCDIC (data transformation)
- re-route the message (network transformation)
- switch from a synchronous protocol to an asynchronous protocol or vice versa (timing transformation)
Items (data, routes, timing, etc.) that may be "morphed" or "transformed" en-route to delivery are not issues related to coupling. They exist between interfaces and do not violate encapsulation. In dealing with synchronicity one must be careful; it means different things to different people. For instance:
1. I made the call using an asynchronous protocol, but blocked for the result.
2. I made the call using a synchronous protocol; an intermediary picked it up (synchronicity facade), and re-sent it as an asynchronous message, then correlated it back to me.
3. I made the call using a synchronous protocol, but spun the call off in a new thread (client side handler), thus it didn't block.
So, a service may have stated that, "I use a synchronous HTTP only"... but the fact is the client (consumer) just plain didn't care. Synchronicity can be morphed because it lies outside of the encapsulation boundary. Synchronicity can be decoupled as a concern. In no way does synchronous behavior adversely affects the loose coupling of services. "Time Coupling" doesn't exist.
No comments:
Post a Comment