Archive

Posts Tagged ‘cairngorm architecture’

Brief introduction about cairngorm

May 16, 2009 1 comment

Hi to all, I have been developing widgets using flex for the past two months and i have not developed using any MVC framework. When people told me that flex application should be developed using cairngorm i have not taken seriously because they have not given reason for why it should be developed with cairngorm. But today i have learnt from my mistakes and known why it should develop with cairngorm and also wish to spread an awareness about importance of cairngorm. here it goes.

Cairngorm is mostly used & well known micro architecture for building and integrating flex application with services. It has been in constant use since flex 1.5 , all because of once you have developed flex application then developer who have not been part of development of flex application can take over and continue the project without any hassles. To describe cairngorm in laymen perspective, it is nothing but divide the code in to logical functions. They are follows.

  • View
  • Model locator
  • Front controller
  • Command
  • Business delegate
  • Service locator

View

It describes user interface (UI) of flex application as well as it bounds the data in the model locator so that whenever the data in the model locator changes, the data bounded to the view will also be updated. so the user dont need to refresh the application when data changes, it will be updated automatically if it has bounded the data in the model locator.

Model locator

It is a centralized location for storing & retrieving data in flex application. It is a singleton class so that the user could not create more than one instance throughout the flex application. The user can retrieve and store the data in model locator using getInstance() static method which will return model locator instance and using that we can push & pop the data from model locator.

Front controller

The role of front controller is map the event name to the corresponding command class. When user triggers an event, the event class will inspect & redirect to corresponding command class which has been defined controller class.

Command

Command class is the one which creates an instance of delegate class and also invokes method of the delegate class which in turn invokes services defined in the service locator. When the services has been invoked, the delegate will return control to command class and the result or the fault method will be executed depend on the result of service invocation.

Delegate

The method defined in the delegate class will invoke the service using static method of service locator i.e. ServiceLocator.getInstance() which will return service locator instance and with the help of that we can invoke the service and also register the class which will handle the result of the service  invocation (generally it will be handled by command class)

Service Locator

This is where we will define all the services which we will invoke from  delegate class of our flex application.

Conclusion

Here i have tried to give an introduction about each  logical functions of cairngorm micro architecture. I have been trying to get good docs about cairngorm micro architecture for the past two months. once i have got, i will post more details about cairngorm in detailed manner. Thank you for reading this post.

Advertisements