Tuesday, June 23, 2009

Fast Flex Cairngorm Explanation

Flex Cairngorm fast explanation

As an experienced Spring and Spring MVC developer, i started my new Flex-Java based personal project with the idea of using a flex framework that encourages the same kind of patterns that i'm used to.
I took on the Cairngorm framework from de Adobe people.

I'll try to establish correspondences between Cairngorm elements and Spring MVC elements.

The elements:

The elements that form part of a Flex Cairngorm Architectura are the following:

View: The view is normally an mxml file. The view shows the data to the user and receives his interactions. The view allows to initiate updates of the model. When an update is to happen, it generates an appropiate event informing of this. The view holds a binded reference to the model that is automatically updated on change. This Object corresponds to the JSPs (Or any other view technology) in Spring MVC.

Model Domain Objects: Are the objects that form part of the Model of the application, are the objects on which the application logic is applied.

Events: Is the flex preferred way of communicating that an action must be taken due to something happening. In cairngorm, the Event object usually carry a Model Object reference on it. This object corresponds, more or less, to the HttpRequest that is sended to the Servlet Container on the Submit event.

Front Controller. As in the major of MVC frameworks, the front controller is the central piece that ties together and routes flow between the view and the business logic. If you are familiar with Spring MVC, this Object corresponds to the DispatcherServlet of Spring.

ModelLocator: In Flex, a Model locator is a Registry that contains references to the different model objects.

Command Objects: Following the GoF Command design pattern, Cairngorm Command Objects are objects that implements an execute method, and are selectively invoked by the front Controller to carry on certain business logic. In normal cairngorm applications, the command object basicaly only extracts the model object from the Event object and passes it to a Business Delegate Object. If you are experienced with Spring MVC this Command Object corresponds to the Controller in the Spring MVC Framework.

Business Delegate: This object's job is to hold a reference to the (usually remote) Service that is going to be called. (Usually this reference is obtained from a ServiceLocator). The business delegate Calls the remote object, and on response, invoke's the Command Object's result method, which is in charge of updating the model in the Model Locator.

No comments: