Purpose
Cairngorm is an approach to organize and partitioning
o Code and package
o Component functionality and roles
Cairngorm is a “best practice” methodology for Flex software design and development.
Cairngorm encourage developers to identify, organize and separate the code base on it’s role and responsibility
Role Type
Cairngorm MVC Layer
DATA
MODEL
GUI
VIEW
Business and Data Access
Controller
Components or Cairngorm
Cairngorm has 5 primary components that are used with Flex RIA solution
Model Locator: A repository for global data and global access
Service: a repository for pre-configured RDS components
Commands: Non UI components that process business logic
Events: custom events that triggered the business objects [ commands ] to start the processing
Controller :Component needed to route business events to commands for processing
FSTOP with Cairngorm MVC
Model
ModelLocator * Photo
View
Fstop, Galary, Shopping Cart
Controller
Fstop Controller * Services *
AddPhotoToCartEvent AddPhotoToCartCommand
LoadPhotosEvent LoadPhotosCommand
Model Locator:
Model Locator is global singleton repository for shared or global data
Does not load or persist data to a permanent data store
Does not contain business logic
Serves as caching and access location only
Caching custom variable/data specific to application
Supports data binding to auto-notification of data changes to view
Service Locator:
The ServiceLocator pattern is used to create a global, singleton registry to centralize all instances of Flex RDS components used in an application
HTTPService
WebService
RemoteObject
Custom RDS classes
Cairngorm events:
Many events take place in Flex applications, but Cairngorm is only concerned with Business Events
Introducing the concept of Business Events:
Flex uses an event delegation model
A System where responses and reactions to activity in one component are delegated to one or more different component
This delegation is achieved by dispatching events
Flex has many categories of events
System events: Initialize, creationComplete, show Effect
Framework Events : click, mouse move, keydown
UserEvents: hideContactsDetails, showCatalog
Business Events: GetAllPurchageItems, LoadCatalog, SubmitOrder, Login User
Data Service Event: Result Event, Fault Event
Custom Events can be used to transport and package data to the recipient(s)
User events are custom events that are delegated to the other components in the Viewer Layers
Custom Events are
Custom Events delegated to components in the business [control] layer
Used to announce gestures and active command processing
Cairngorm Even Code
Each event should have unique ID that is exposed statically and passed to the super constructor
Simple Event
Using a Cairngorm Event
The viewer layer can create and dispatch Business events
The control layer can create and dispatch Business Events
Only control layer manages and processes business events
Dispatching of business events should be considered one way to the business [control] layer
Cairngorm event dispatch themselves to the controller
Implementing Commands
The control layer relies on Commands to manage business logic and responds to business events
Command features
Each command class represents a specific business features with associated business logic and processing
Commands updates the model locator with new data and changes to the existing data
Each command class represent a specific business features with associated business logic and processing
All commands have same entry point to initiate or start the business processing
Command implementations have class names to that are equivalent to Business events
LoadPhotosEvent and LoadPhotosComamnd
Using the Command
Used in the controller where events are listened for and corresponding commands are called
Sunday, January 25, 2009
Cairngorm And Flex
Subscribe to:
Comments (Atom)
