Session Facade, meet Business Delegate and his friend Service Locator…

September 27, 2007

A general introduction: The Session Facade enterprise design pattern allows you to create a clean, well-defined interface to complex and/or composited business objects. The Service Locator is an object that gives you a one-stop shop for all your service needs. It holds a reference to all of your services whether they are Remoting, web services, http service calls or other external resources. The Business Delegate is a layer of separation between the Service Locator and the control (command) code, which is very helpful in Flex as it’s an excellent place to setup your responders to the asynchronous calls that you will make and handle service problems.

Facades

The Facade pattern is widely used and usually without notice… Anytime you create a class that has a simple interface to mask complex or more volatile objects, you are using the facade pattern. The Session Facade pattern is an implementation of the Facade pattern where service calls are made to an object that masks business object method call and services call aggregation/composition. I enjoy the luxury of using ColdFusion to perform this task. With one CFC you can create a Session Facade that enables Flex to make Remoting calls and allow other clients to consume the facade as a web service. If you don’t carry your DTOs (Value Objects) into the business layer you will also use the Session Facade as a place to create DAOs from your DTOs for use in the business layer (which usually employs a pattern known as Transfer Object Assembler). ColdFusion makes this process easier as well, you can simply iterate through the DTO struct and copy required entries to the DAO structure (this works in both directions of course).

Service Locator

The Service Locator is helpful to the client. You should point your business delegates and any view helpers that make service calls to one object. That object is the Service Locator and it contains the configurations for access to any services you are going to use.

Business Delegate

A Business Delegate will help minimize impact on your client code when the server side interface changes. This also gives you a smart place to do some exception handling and missing service decisions. When used with the command pattern and the Service Locator this object is really helpful as a place to create a simple service interface for the commands.

2 Responses to “Session Facade, meet Business Delegate and his friend Service Locator…”

  1. Jose Lopez Says:

    What is the diference between delegate(in genral not busines delegate) and facade(not specifically session facdae)?

  2. etweb Says:

    A delegate represents something and a facade simplifies the interface to something… in a very general statement. A business delegate is the local representation of the service, so the majority of your code does not have to reach out to the service directly. A facade, like the session facade, gives you just what you need. The actual methods exposed on the service may be many, but if you only need a couple of methods for your session, then you will access the service through a facade that only contains what you need. Hope this helps.


Leave a comment