O'Reilly logo

Professional Cairngorm™ by Jeremy Wischusen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.1. What Are They?

Commands are the classes that determine how the event that triggers them should be handled. According to the article "Flex 3: Introducing Cairngorm" (Adobe Customer Training/Partner Enablement Group, Burleson, Shuman, and Boles), the commands have the following characteristics:

  • Each command class represents a specific business feature with associated business logic and processing.

  • Commands update the ModelLocator with new data or changes to existing data.

  • All commands have the same entry point to initiate or start business processing: execute().

  • Command implementations have class names that are equivalent to business events (e.g., LoadPhotosEvent and LoadPhotosCommand).

Commands classes decide how Cairngorm events are handled. When a Cairngorm event is dispatched, the FrontController calls the execute function on the command class that is registered for the event.

The execute function contains the logic that needs to be executed. This may include accessing remote services using a delegate class or it may simply update the ModelLocator. Regardless of whether services are used or the ModelLocator is simply being updated, command classes are the only classes that should be updating data on the ModelLocator.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required