





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
this will help you to make a better design
Typology: Lecture notes
1 / 9
This page cannot be seen from the preview
Don't miss anything!






Page | 103 INTERACTIVE SYSTEME DEVELOPMENT FRAMEWORK Topic:
Learning Outcomes:
Introduction Obviously, a complete application consists not only of UI objects, but those for the core functions of the application as well. How do we effectively develop the larger interactive programs with two such parts (i.e., UI and internal functional core)? It is a good idea to follow an established development framework or methodology suited for highly interactive systems. A development framework refers to a modular approach for interactive program development where the core computational and interface parts are developed in a modularized fashion and combined in a flexible manner. Such a development framework is often based on the UI toolkit, which provides the abstraction for the interface parts. The framework allows the concept of plugging in different interfaces for the same model computation and easier maintenance of the overall program. In addition, such a practice also promotes the productivity as well as easier and less costly post maintenance. MVC (model, view, and controller) is one such major framework. **Content
Page | 104 methodology. With the MVC framework, the application is divided into three parts: (a) model, (b) view, and (c) controller, as illustrated in Figure 7.1. The model part of the application corresponds to the computation (e.g., realized as objects) that deals with the underlying problem or main information or data of the application. For all practical purposes, once in place, a model of the application tends to be stable and unchanging. For instance, in an interactive banking application, the model will be parts of the program that maintain the balance, compute the interest, make wire transfers, etc. The model has no knowledge of how the central information will be presented to the user (output/presentation) or how the transactions (input) are made. 2) View The view part of the application corresponds to the implementation for output and presentation of data. In modern GUI-based interfaces, the implementation will typically consist of widgets. For instance, views might be windows and widgets that display the list of transactions and the balance of a given account in a banking application, or they might play a background audio clip depending on the score level for a game. As a whole, there may be multiple views for a single application (or model). For instance, there could be different view implementations for different display platforms or user groups (e.g., 17 - in. monitor, 10 - in. LCD, HD resolution display, display with vibrotactile output device, young users, elderly users). Note that the output display does not necessarily have to be visual. Anytime the model is changed, the view of that model must be notified so that it can change the visual representation of the model on the output display. The region/portion of the
Page | 106 (view/controller) for the same core functional model. This is based on a famous software engineering principle: the separation of concern. Example of MVC Implementation 1: Simple Bank Application We illustrate a very simple object-oriented implementation for an interactive banking application. In this simple application, the model maintains the balance for a user who can make deposits or withdrawals through a computer UI. Figure 7.2 shows the overall structure of the application according to the MVC architecture. In Figure 7.2, as for the model part, a class called Account maintains the customer name, balance, and two views/controllers (one for displaying the balance and realizing the UI for making deposits, and the other for withdrawal). The model has two core methods for maintaining the correct balance when a deposit (Account::Deposit) or withdrawal (Account::Withdrawal) is made. These two methods use the Notify_depositVC and Notify_withdrawalVC to notify the corresponding view to update the balance in the display. In this particular example, the View and Controller parts are merged into one class, called the AccountViewController, which has a pointer to the corresponding model object (as the recipient of the notifications and model change queries). This class is a subclass of a more general UIObject that is capable of housing constituent widgets and reactive behavior to external input. It is also the superclass for subclasses, the DepositViewController and WithdrawalViewController, which implement the two views/controllers for the given model.
Page | 107 The subclasses, among others, implement three important virtual methods: Init_ui_display, Update_ui_display, and Handle_ui_event (Figure 7.2). Each of these is responsible for creating and initializing the display and UI objects within the view/controller, updating the display (invoked by the notification method from the model, as seen in Figure 7.3) and handling the user input. Figure 7.4 shows the Handle_ui_event method of the DepositViewController that interprets the user input (e.g., textual input of digits into integers) and invokes the model method, for example, to make a deposit by calling my_model-
Deposit(deposit_amount). Understand that this will eventually change the model, and the view/controller will be notified to change its display (e.g., to show the proper amount of balance after the deposit). Although not shown, the WithdrawalViewController would be coded in a similar manner.
Page | 109 Example of MVC Implementation 2: No Sheets As a second example, we will illustrate parts of the implementation code for the No Sheets application introduced in Chapter 4, as shown in Figure 7.5. The core of the model is music information, a list-based data structure that contains the chord information for a piece of music that is read from a user-selected file. Aside from the music information itself, there may be other model variables such as the music file name, tempo value, etc. Thus, the model information is updated by and read from the view/controller objects.
Page | 110 The view/controller is composed of several Activity (screen interface) objects. The SmartChordActivity represents the main front-end interface, which allows the user to apply certain major actions such as selecting/loading the music file, selecting the tempo, playing the chosen music file, and other miscellaneous functions. It will access information from the model—for instance, the name of the current file and current tempo—and show them in the interface. FileActivity represents the file-selection interface screen, which presents the user with a list of available music files. The user makes a selection, and the FileActivity will construct the internal chord-event list and update the model. Likewise, TempoActivity allows the user to select the tempo and update the model accordingly. Finally, the PlayActivity accesses the event-list data structure of the model and presents the musical information at a given tempo (no model updating is carried out). Self-Assessment Question: