Section 4.2. The User Interface


[Page 150 (continued)]

4.2. The User Interface

The user interface is the part of a program that handles the input and output interactions between the user and the program. As an interface, it limits or constrains the manner in which the user can interact with the program.

User Interface


Computer programs are just one of the many things that require a user interface. Virtually every device we use has one. For example, consider again the difference between the user interface of a digital versus an analog watch. A digital watch has a display that tells you the time to the exact hour, minute, and second. An analog watch, one with a sweep second hand, can never display the time to the exact second. Similarly, a digital watch has buttons that let you set the time to the exact hour, minute, and second. An analog watch has a small wheel that allows you to set the time only approximately. Thus, the user interface constrains the kinds of interactions that are possible between the user and the device.

With regard to our Java programs, one way to divide up the labor is to distinguish between the user interface and the computational functions. The role of the user interface is to transmit data back and forth between the user and the program. The role of the computational part of the program is to perform some kind of computation, in the broad sense of the term. The computation might be to play a game, or calculate a square root, or monitor a hospital patient. Figure 4.1 provides a generic picture of the relationship between the user interface and the computational object.

Figure 4.1. The user interface transmits data back and forth between the user and the program's computational objects.


Division of labor


In this chapter we focus our attention on the user interface side of the relationship shown in Figure 4.1. In subsequent chapters we will focus more on the computational side of the relationship. What we desire is an approach that lets us combine a computational object with any one of the three different kinds of user interfaces.


[Page 151]

Effective Design: The User Interface Module

Separating the user interface from the computational object is a good way to divide up the labor in programs that perform I/O.





Java, Java, Java(c) Object-Orienting Problem Solving
Java, Java, Java, Object-Oriented Problem Solving (3rd Edition)
ISBN: 0131474340
EAN: 2147483647
Year: 2005
Pages: 275

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net