# Beginning to Design Web Applications

When our programs are very small, we can usually just write them. We don't need to plan much. However, modern software can have hundreds of thousands of lines of code. Maybe some planning is appropriate? During this semester, as our programs get more and more complex, we're going to explore ways to think and plan out what to do.

## Problem Statements¶

• We will start working on our programs with a problem statement.
• These are a few paragraphs that describe the program that you will be writing. This is usually written by non-programmers and is intended to communicate to you, as best they can, what they want.

### Examples¶

Write a program that asks a user for 10 numbers. The program will then determine the smallest number, the largest number, and calculate the average of the number. The program will display the three calculated values.

Write a program that asks a user to enter the height of a child for each year of their life. The program will then determine which year the child grew the fastest and which year the child grew the slowest and output the calculated values.

Write a program that asks a user to enter a temperature in Fahrenheit and convert it to Celsius. The program will display the Fahrenheit temperature and the calculated Celsius temperature. A Celsius temperature is calculated by the formula 5 / 9 times Fahrenheit temperature minus 32.

## Extracting the Nouns and Verbs¶

The first step in our planning is to look at the important words in the problem statement. Which nouns and verbs do I have to pay attention to?

Here's how do to this with the below example:

Write a program that asks a user for 10 numbers. The program will then determine the smallest number, the largest number, and calculate the average of the number. The program will display the three calculated values.

#### 1. Look at the important nouns¶

Write a program that asks a user for `10 numbers`. The program will then determine the `smallest number`, the `largest number`, and calculate the `average` of the number. The program will display the three calculated values.

• 10 numbers
• smallest number
• largest number
• average

#### 2. Look at the important verbs¶

Write a program that `asks` a user for 10 numbers. The program will then `determine` the smallest number, the largest number, and `calculate` the average of the number. The program will `display` the three calculated values.

The verbs

• determine
• calculate
• display

## Creating the Program Planning Lists¶

The next step is to take these nouns and verbs and make some checklists. This is a quick and fairly informal process. Don't get too hung up with being perfect or complete. We are trying to capture the high-level lists of key items in the program.

#### The three list we want to make are:¶

1. The list of input variables
2. The list of output variables
3. The checklist of processing steps

#### 1. The List of Input Variables¶

Looking at our list, the 10 numbers are input into our program. We need to list out each variable we will need to capture the 10 inputs. It's best to write out the variable name you actually intend to use.

Input-variables

1. numberOne
2. numberTwo
3. numberThree
4. numberFour
5. numberFive
6. numberSix
7. numberSeven
8. numberEight
9. numberNine
10. numberTen

#### 2. The List of Output Variables¶

Next, look at the nouns for things that the program will need to output or display. Be careful here, sometime an input variable is ALSO and output variable. Again, I've written the variable name I plan to use in my program.

Output-variables

1. smallestNumber
2. largestNumber
3. averageNumber

#### 3. The Process Checklist¶

Here's where we start in on developing what our program actually does. This list will be very high-level, you don't need to have any detail! Here we will take our verb list to create a process checklist. Each verb is a candidate for being on our list of steps.

The first verb is ask. What you are doing is getting input. That will be your first item on your list of steps your program is going to do. We're just going to convert it a little so it sounds more like we are programming it.

• Prompt user for 10 numbers

Then next two verbs are determine and calculate. This is the heart of the program. It's what the program is all about. The process step just has to say a little more.

• Determine the smallest number
• Determine the largest number
• Calculate the average

The last verb is display. This is the output step. Be brief!

• Display smallest number, largest number, and average.

Process-checklist

1. Prompt user for 10 numbers
2. Determine the smallest number
3. Determine the largest number
4. Calculate the average
5. Display smallest number, largest number, and average.

Read this to yourself, does it sound complete? Does is sound like a program? Now let's make it into a program!

## Hands on work¶

Labs

1. Beginning to plan
• unit01/labs/lab-07-planning.html

Exercises

1. Lab07 exercise
• unit01/exercises/exercise-07.html