7.1. Views and EditorsBefore getting into the details of how to create the chat editor, let's step back a bit and consider whether it should be a view or an editor. When you created the Contacts view in Chapter 5, "Starting the Hyperbola Prototype," we mentioned that views and editors contain the "real content" for your application. But how do you choose which one to use? The rule of thumb is that editors are meant for the primary focus of attention while views provide supporting information for a given task. So, in Hyperbola, chatting is the primary task and browsing or managing contacts is a supporting function. This indicates that the Hyperbola chat area should be implemented as an editor. Not all decisions are quite that clear-cut, however. Even the choice made here has been hotly discussed by the Hyperbola development team. It is, of course, technically possible to use a view to represent a unique chat instead of using the chat editor (an excellent exercise for the reader). Here is a short list of differences between views and editors to help you decide which to use for your application:
In Section 16.2.1, "Multiple Instances of the Same View," we show that it's possible to have multiple instances of the same view, so it is possible to allow chatting from within a view, or even better, in a separate window. For now, we use the editor mainly because you already know how to create a view and this gives us a chance to look at how to use editors. |