7. Input/Output: Designing the User Interface

7.1. Introduction

One of the most important parts of learning a programming language is learning how to program an application to accept input and produce out- puts (I/O). Computers wouldn’t be very useful if we could not give them data to manipulate and compute, and if we were not able to read or un- derstand the results that they produce. In general, a computer program’s input and output capabilities are known collectively as its user interface.

An input operation is any action that transfers data from the user to the computer’s main memory via one of the computer’s input devices. An output operation is any action that transfers data from the computer’s main memory to one of the computer’s output devices.

In this chapter, we will introduce three simple user interfaces: a command-line interface and two graphical user interfaces (GUIs). These interfaces can be used interchangeably with the material in most of the subsequent chapters. Indeed, one of the most important design princi- ples that we emphasize in this chapter is that the user interface should be designed to function independently of the computational task. In other words, it should be possible to take an application, such as a computer game, and design it so that it can be used with a variety of different user interfaces.

 

 

 

 

User interface

 

 

 

 

 

 

 

 

 

 

 

 

Division of labor