Designing a Program

Usually, when you have to write a program, you're not told exactly what code to write, as I've been doing throughout this course in the handouts. More often than not, you're given (or you think up) a very high-level description of the program you are to write, and you must go from there. This section will describe how to write a program starting at this point.

Program Definition

This is where you start. The program definition is a high-level description of the program written in plain English, though it should describe the program as completely as possible without getting into specifics. Let's use an example:

Write a program that will convert from Farenheit to Celcius.

Program Specification

From there, the program designer writes the program specification, which describes the program in a much more rigorous and specific fashion (though it's still in English).

  • The program to convert from Farenheit to Celcius shall have the following three controls: a text box, a label, and a command button.
    • The user shall be able to enter a number corresponding to a Farenheit temperature into the text box. The text box shall initially be empty.
    • The label shall serve as a container for the Celcius temperature corresponding to the Farneheit temperature entered into the text box. The label shall intially display no value.
    • When the user clicks the command button, the value of the text box shall be read, converted to Celcius, and displayed in the label. The command button will be labelled Calculate.

Program Design

Once the program is specified, it can be designed. This usually involves sketching what the windows will look like, and writing out "pseudocode" (i.e. a description of a process, written in a code-like language).

There will only be one window. All the controls will be in one row; the text box, then the command button, then the label.

The code for the Calculate button should look like this:

Label = 5 * TextBox / 9 - 32

The text box should be named txtFarenheit, the label should be named lblCelcius, and the command button should be named cmdCalculate.

Once the program is designed, it can be written. Everything should fall into place now, and actually creating the program should be almost trivial.

This may look like an awful lot of work to do just to write one simple program, but you can imagine how much this would help if you were writing, say, an e-mail client.

Designing a program in this fashion also helps you to iron out the bugs, before you actually start coding. High-level conceptual ideas can be evaluated as part of the program as a whole, when you're dealing with the rest of the application at the same level.

I'd say, from experience, that every hour you spend designing your program will save you at least four or five hours when you're actually writing the program. Get into the habit now of designing your programs before writing them, and you'll spend a lot less time debugging for the rest of your life.


The Intro to Visual Basic homepage is hosted by GeoCities