Software Development

Phases of Software Development

There are seven (7) Phases of Software Development.

Specification of the task

Design of a solution

Implementation of a solution

Analysis of the solution

Testing and debugging

Maintenance and evolution of the system

Obsolescence

Pseudocode

What is pseudocode?

An example of pseudocode

Suppose your task is to write a multi-function conversion program that a cook could use in the kitchen. Common conversions might include:

The cook will choose a function and be prompted for the appropriate input. The program should output the result after conversion and return to the function selection prompt. This should continue until the cook desires to exit the program.

You're probably already thinking of ways to solve this problem, so all you need to do is take it one step further and actually write it down. Here's one way of solving the above problem:

Prompt the user with a numbered list of conversions and a choice to exit
While the user wishes to continue entering conversions, do:
  Read the user's choice and determine which conversion to call
  If the user chooses Celsius⇔Fahrenheit, then:
    Prompt user to input temperature, then a space, then 'C' or 'F'
    If temperature is Celsius, then:
      Multiply temperature by 9/5 and then add 32
    Else
      Subtract 32 from temperature and multiply the result by 5/9
    Output the resultant temperature
  Else if the user chooses Pounds⇔Grams, then:
    Prompt user to input weight, then a space, then 'lb' or 'g'
    If weight is pounds, then:
      Divide weight by 0.0022046
    Else
      Multiply weight by 0.0022046
    Output the resultant weight
  Else if the user chooses Ounces⇔Milliliters, then:
    Prompt user to input volume, then a space, then 'oz' or 'ml'
    If volume is ounces, then:
      Multiply volume by 29.574
    Else
      Divide volume by 29.574
    Output the resultant volume
  Else if the user chooses to exit the program, then:
    Exit the while loop
  Prompt the user with a numbered list of conversions and a choice to exit
Notify user that program is exiting and exit program

Now, sure, that's a lot of work to do in the text above, but you'll notice a few familiar statements like if, else and while. These concepts are nearly universal in modern languages so if you later decided to implement your C++ program in Java or Python, you'd simply need to find the appropriate statements in that language!

Since we're interested in using a multi-file approach in our program, you might decide to do something like this:
(note: brevity of pseudocode used for consideration of space and conciseness)

main.cpp

#include <iostream>
#include "celsiusFahr.h"
#include "poundsGrams.h"
#include "ouncesMilli.h"

int main()
{
 // prompt user for input
 while(/*user wants to continue*/)
 {
  // read user input

  // if temperature, call celsiusFahr
  // else if weight, call poundsGrams
  // else if volume, call ouncesMilli
  // else if exit, break from loop

  // prompt user for input
 }
 // notify user of exit
 return 0;
}
celsiusFahr.h
// returns the temp conversion
int celsiusFahr(/*fill me in*/);

celsiusFahr.cpp
#include "celciusFahr.h"

int celsiusFahr(/*fill me in*/)
{
 // prompt for temp and unit
 // if unit is Celsius
  // multiply temp by 9/5
  // add 32 to temp
 // else
  // subtract 32 from temp
  // multiply temp by 5/9
 // output the resultant temp
}
poundsGrams.h
// returns the weight conversion
int poundsGrams(/*fill me in*/);

poundsGrams.cpp
#include "poundsGrams.h"

int poundsGrams(/*fill me in*/)
{
 // prompt for weight and unit
 // if unit is pounds
  // divide weight by 0.0022046
 // else
  // mult. weight by 0.0022046
 // output the resultant weight
}
ouncesMilli.h
// returns the volume conversion
int ouncesMilli(/*fill me in*/);

ouncesMilli.cpp
#include "ouncesMilli.h"

int ouncesMilli(/*fill me in*/)
{
 // prompt for volume and unit
 // if unit is ounces
  // multiply volume by 29.574
 // else
  // divide volume by 29.574
 // output the resultant volume
}

You'll notice that there is some actual code in the files, such as includes and function declarations that are anticipated. There are also function prototypes and loop conditions that are not complete. This is okay! You may not know exactly what the parameters will be, but the comments are there so you can come back and fill it in later. We're essentially building a sort of framework for our code to inhabit later. It doesn't take much of an imagination to turn this framework into a functioning program. When it comes time to start coding a project, you'll be glad you have this!


In class Exercise

Model the 'communicator' from Star Trek the Original Series, with pseudocode, specifically describing it's behaviors given how the user interacts with it. You need to think about the details! Also consider what happens if a connection is lost (you can come up with your own ideas here). In short, opening a communicator plays a tone and establishes a connection. Closing terminates the connection. Check out this video.

Original notes by Prof Christopher W Brown