SOA Pattern of the Week (#1): Service Façade
Join the DZone community and get the full member experience.Join For Free
thomas erl ( soaschool.com) and herbjorn wilhelmsen , ( objectware ), bring you the first soa pattern of the week, a series comprised of original content and insights provided to you courtesy of the authors and contributors of the soapatterns.org community site and the book “soa design patterns.”
one of the fundamental goals when designing service-oriented solutions is to attain a reduced degree of coupling between services, thereby increasing the freedom and flexibility with which services can be individually evolved. achieving the right level of coupling “looseness” is most often considered a design issue that revolves around the service contract and the consumer programs that form dependencies upon it.
however, for the service architect there are opportunities to establish intermediate layers of abstraction within the service implementation that further foster reduced levels of coupling between its internal moving parts so as to accommodate the evolution and governance of the service itself. these intermediate abstraction layers are created by the application of service façade , a design pattern focused on intra-service design.
when designing a service, there are several negative coupling types you need to look out for. contract-to-logic coupling, for example, results in a service contract that is derived from (and therefore may have formed dependencies upon) the underlying service logic, which makes the contract subject to change whenever the logic changes. the result is, predictably, a cascading effect whereby all service consumers are impacted (usually negatively) by the changes.
service façade can help avoid these situations by establishing an intermediary processing layer in between the core service logic and the service contract. the façade logic allows the service contract to remain decoupled from the underlying logic and further shields it from changes to the core business logic. this applies to both functional and behavioral changes, the latter of which may (often inadvertently) come about as a result of applying the service refactoring pattern. the façade layer can compensate for internal changes so that the service contract does not need to be modified as a result of the changes and/or the behavior of the functionality expressed in the contract is also not affected. in both cases, the service can evolve internally while existing service consumers remain protected from any potential side-effects.
another scenario that can be effectively managed through the application of this pattern is when a single body of core service logic requires multiple contracts (a situation that actually pertains to another pattern called concurrent contracts ). in this case, a separate service façade component can be created for each service contract, thereby retaining a clean abstraction of core service logic from the contract layer. this avoids having to augment and bloat the core service logic over time in order to accommodate different contracts and can further leverage the aforementioned benefits of functional and behavioral compensation when that logic is subject to functional change or refactoring efforts.
the service façade pattern can result in an elegant service architecture with clean layers of abstraction, but it can also impose extra processing overhead that naturally comes with increasing the physical distribution of service logic. the fact that service logic ends up being more distributed can also be perceived as increasing the complexity of the service design as well. carefully minding the type of logic placed in façade layers will help mitigate these issues.
overall, though, the intelligent and regulated application of this pattern can result in an effective separation of intra-service processing responsibilities, which brings with it numerous governance benefits that can accommodate the long-term evolution of the service and further help to preserve on-going relationships formed with service consumer programs.[img_assist|nid=7485|title=|desc=|link=none|align=right|width=90|height=116]
the soa pattern of the week series is comprised of original content and insights provided to you courtesy of the authors and contributors of the soapatterns.org community site and the book “soa design patterns” (erl et al., isbn: 0136135161, prentice hall, 2009), the latest title in the prentice hall service-oriented computing series from thomas erl ( http://www.soabooks.com/ ).
Published at DZone with permission of Herbjörn Wilhelmsen. See the original article here.
Opinions expressed by DZone contributors are their own.