22.8. Summary

In this chapter you consolidated event and command classes with related functionalities. You then revised the existing features of the sample application to use these new classes. Let's take a moment to examine the basic process that you used to do this.

Discrete event classes became type constants in a common event class. They were generally grouped together by the object they centered on (e.g., posts) and the value objects they used to pass data (which on some level are related to the central object).

In some cases the same event class would need to pass multiple types of data (e.g., comments and search). If this was the case, the property used to transfer data was typed to Object and stored in the inherited data property of the CairngormEvent class. It then became the responsibility of the command class to cast the data property to the appropriate type.

You consolidated delegates with similar purposes by moving related functions into a single delegate class.

You can see, from this exercise of updating the existing features, some of the flexibility afforded by using an application framework. The changes you had to make were generally the same across features (update how events were dispatched, update commands, and so on) and the locations in which you made the changes were predictable. On the other hand, you can also see that you probably want to decide how you are going to structure your events and delegates before you start to code the application, since the ...

Get Professional Cairngorm™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.