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

21.5. Looking Toward Version 2

As mentioned earlier in this chapter, despite the structure provided by Cairngorm, there are still different ways of accomplishing the same thing.

One of the major complaints about Cairngorm is that it requires a lot of classes to be created. If you examine the src/com/FlexBlog folders you currently have, you'll see these:

  • Commands: 14 classes

  • Controllers: 1 class

  • Delegates: 9 classes

  • Events: 14 classes

  • Models: 1 class

  • Value objects: 5 classes

  • Views: 17 components

Ignoring the main application file and the database helper classes, this brings you to a total of 61 classes. Taking into account how simplified this application is, you can imagine that the full application would have many more.

While the recommended use of events, commands, and delegates is to have a one-to-one correspondence, this is not absolutely necessary and you can reduce the number of classes by combining classes with similar purposes.

Take events as an example. In the events that you created, the type parameter was removed from the constructor in favor of a constant defined in the event being directly passed to the parent constructor. Since there is a one-to-one correspondence between event and command classes, doing this enabled you to dispatch the event without specifying the type (since it would always be the same anyway). However, if you leave the type parameter in the constructor and simply define different constants for different types of events (which is more or less how the ...

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