Saturday, April 03, 2010

Introduction to Programming: Starting Out With Programming Logic and Design: Chapter 11: Menu Driven Programs

Starting Out with Programming Logic and Design (2nd Edition)

1. Introduction to Menu Driven Programs

A menu driven program displays a screen of options that a user can make a choice from, usually by typing a number or a letter.

Using Decision Structure to Perform Menu Selections

To make menus easier in programs most Languages have a Case structure. This allows for the user to enter input and the program Check it against what the program expects as inputs. While it is the simplest, it is not the only way. An if..than...else series will do the same thing.

Validating the Menu Selection

The case selection should have as its default if nothing matches a way to exit the program gracefully or even better, loop back and ask the user to do it again. Another way to do this would be to use while loop after the display asking for input and validate that you have gotten a correct response.

2. Modularizing a Menu Driven Program

In order to simplify things in menu driven programs, the suggestion is to break the parts of the program into modules. There would be one main module that would call a menu module. The menu module would display the menu and validate input returning the menu choice to the main module. With that choice the main module would call the module it needs.

3. Using a Loop to Repeat the Menu

If using a menu, you most likely want to leave the menu up till the user exits it. The best way to do this is to give a menu choice to exit the program and then use a loop to keep presenting the menu when a program ends. When a user exits a module it will present the menu again till the user exits it.

4. Multiple-Level Menus

Big menus are not good so often there is a need to break them up into smaller menus with menu choices calling up other menus. To do this you would use the same modular style and call the sub menus from main. Then that module would call the other menus.

 

The Psychology of Menu Selection: Designing Cognitive Control at the Human/Computer Interface (Human/Computer Interaction)


No comments:

Post a Comment