There are seven (7) Phases of Software Development.
Suppose your task is to write a multi-function conversion program that a cook could use in the kitchen. Common conversions might include:
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
celsiusFahr.cpp
|
poundsGrams.h
poundsGrams.cpp
|
ouncesMilli.h
ouncesMilli.cpp
|
You'll notice that there is some actual code in the files, such as include
s 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!
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