Accessibility

Table of Contents

Developing Flex RIAs with Cairngorm microarchitecture – Part 6: Rapid and consistent development with Cairngorm and Flex

Cairngorm flow of control

The previous sections describe the flow of control through the various design patterns in a Cairngorm architecture. Each and every feature in an application traces the same flow of execution, with user gestures becoming events, events becoming service calls, and data passing back into the model.

Adding a new feature to a Cairngorm application

When you add a new feature to a Cairngorm application, it is as simple as the following process:

  1. Register an event and command with the Front Controller using addCommand().
  2. Implement a new command as follows:
    1. Implement the execute() method to do the work.
    2. Implement the result() method to handle any results from the server:

      1. Any results are used to update the Model Locator.
      2. The Model Locator automatically updates the view.
  3. Add any new service calls that the command requires for the Business Delegate.
  4. If these service calls require new services, add them to the Service Locator.

Additionally, you will have to create any Value Objects that are required to pass data between the command and Business Delegate, between the Business Delegate and the server, or to store data on the Model Locator. Typically, however, your Value Objects will exist early in the development of your application and you will normally reuse them as you add new features to your application.

Similarly, as your application grows, the server-side services quickly become locked in place and application development proceeds even more quickly, following a simplified process:

  1. Register an event and command with the Front Controller using addCommand().
  2. Implement a new command.

That's really all there is to it.

Debugging a Cairngorm application

Debugging a Cairngorm application involves the same predictable steps. If a desired feature doesn't perform in response to a user gesture, the debug cycle is always the same:

  1. Check whether the event is registered with the Front Controller.
  2. Check whether the execute() method is called on the command by the Controller.
  3. Check that the appropriate delegate methods are called.
  4. Check that the result() method is called in the command.
  5. Check that the model is updated in the Model Locator.

With these five steps, it's painless to isolate a problem in an application and fix it.