Thursday, October 11, 2012

Facade or Wrapper or Mediation?

What is the different between service facade, wrapper service and mediation?

So here's the problem- there's no standard definition on each of these and since different groups of people mixed up the definitions of these and then some vendor sauce was poured over it, things start getting blurry.

Let's go back to the basics:
  • facade - a facade is a component that makes a component appear as something else; 
  • wrapper - a wrapper (or better: wrapper service) is a service that wraps a service or system and makes it appear as something else;
  • mediation - a mediation is a component that makes a component appear as something else.
Facade (or Facade Component)

A facade component is a component inside a service that can be used to mitigate for evolving several aspects of a service without the need to change other parts of a service. For example the facade component (or class) can be used to shield:
  • contract from evolving service logic -or-
  • service logic from evolving back end systems -or-
  • offer multiple contracts for the same logic -or-
  • offer a standardized contract for a non-standardized component -etc.
The facade component is the most commonly applied design pattern in the world of service-orientation because this is what allows a service-oriented solution to be flexible and cheaper to manage (on the long term). It is a solution that helps manage the cascading effects of changes to the implementation of a service or a back end. Knowing when to position (even an empty one) facade component up-front is key to the successful application of this design pattern.

Wrapper Service

A wrapper service is a service wrapping another service or system. The service architecture (the infrastructure inside a service) can actually contain (a) facade component(s) to make its magic work. Many services are -if you looked at them conceptually- wrapper services. Ie. an entity service exposing a standardized contract can contain a core service logic component to access a database to access but it would typically also contain a facade component to make that database access logic appear as something more usable from standardized-service-contract point of view. Also application-specific public service which are there to accommodate for service consumers that cannot adhere to our standardized service contract are considered wrapper services. Ideally this kind of a service would wrap the standardized service and make it appear in a way that the domain specific service consumer can understand.

Mediation (or Mediation Component) 

If we look closely at the short explanation of mediation above, we can see that it is the same as for Facade. This was done intentionally to convey an important statement: Mediation is a specific application of a facade; Vendors need to come up with a new "hot topic" now and again - this is the latest greatest commercial name for something that conceptually existed for a long time but is now introduced as the new miracle glue to make vendor products look more attractive. If push comes to shove, mediation should conceptually not be viewed as anything else than a facade component. If we look closely they even exist inside services on most vendor platforms. As a side note: some vendor platforms allow us to place mediation between services, they are then agents placed in the message flow but the purpose of these is the same as a facade component: to make a service appear in a different way. Usually a form of mapping is involved in one way or another.

- Roger

No comments:

Post a Comment