This chapter contains advice to help you build on the foundations of Cairngorm. It is targeted at developers with an understanding of traditional Cairngorm and consists of the best practices, anti-patterns to avoid, and useful customizations.
Although Cairngorm provides a framework on which to build a Flex application, the quality of the end result depends on many other factors, including:
Testability: If code cannot be tested easily, how can a developer be sure that it works?
Organization: When a project grows rapidly, how can the codebase be kept tidy and navigable?
Dependencies: If dependencies are not minimized, software becomes difficult to maintain.
This chapter addresses these issues. The first section explains how to use Cairngorm in conjunction with the Presentation Model pattern to move view logic into a place where it can easily be unit tested. Guidance for organizing smaller and larger Cairngorm projects follows, before a number of known Cairngorm anti-patterns are exposed; these tend to occur in Cairngorm projects but are easily avoided with a little care and attention. Finally, the topic of customization is covered, including extending the front controller for various purposes, timing the execution of commands, and stubbing the service layer.
The Presentation Model is a design pattern for user interface programming that is particularly well suited to Flex, since it can take advantage of language features such as ...