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.4. How Views Have Been Used

Views have been broken down into discrete components that contain only the code necessary to make the view function. Additionally, you have kept the size of the main application and individual views small by composing larger views out of other components. This is primarily an organization principle that has the same benefits as breaking your code into classes. Namely, it is easier to locate the code related to a given view rather than to search through one large view file. Components can (and should if possible) also enable you to reuse views. For example, you were able to use the PostList view you created for both the recent posts feature and the search feature. In both these cases the fact that the user selected a post from the list meant that the post being displayed needed to be updated. Since the functionality of the PostList view takes care of this by dispatching the SetCurrentPostEvent, you did not need to recreate this functionality in the search view.

Aside from binding to properties of the ModelLocator to update the contents displayed by views, you also bound to them to trigger setter functions that were used to allow views to react to events (such as clearing forms after submission and enabling buttons). Because of this mechanism, the ModelLocator does not need to have any knowledge of what function is being triggered on the view, or any knowledge of the view at all for that matter.

Finally, views triggered actions by dispatching events. ...

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