Problem Specifications
It is important to know the overall appearance and interface to a program before designing a solution, to assure that the correct problem is solved. A common feature to all of the example projects is that some portion of input comes from a data file, and some portion involves interacting with a person at the keyboard.
The first step is to clarify just what that interface looks like.
A. The input data file
A data file would contain information that would not be suitable as keyboard input (too much input, or data the user would not know) and would need to be changeable without rewriting the program.
This requirement of a data file also is to allow the same program work for a sizeable file (12 lines or more) for an ‘interesting’ program, and a smaller one for fast grading. The program may not assume any particular fixed size for this file, but should adapt to the actual file contents.
1. What information is stored in data file for this project?
2. Are all the data lines treated in exactly the same way?
3. If not, then how are the different parts of the file distinguished from each other?
4. Will the entire file be input to the program at first, or periodically through the execution of the program?
B. Keyboard interaction
Interaction with a user is what makes a program interesting. A program that only accepts input from a file and displays an answer, with no further user interface may become boring very quickly. Therefore, this assignment will expect some degree of input from a user at a keyboard.
You may assume that all inputs will be valid. For example, if a number is expected as input, a number will be provided. More robust input verification can be cumbersome for a first course, and is really much less interesting than addressing the actual problem.
1. What sorts of input will be expected from a user in this program?
2. What response would the program provide for each input?
3. Does any user input determine when the program stops running?
4. Provide at least two illustrations of what the user interface looks like.
Problem Analysis
The next important step in program development is to identify what tools are available to solve the problem. There may be existing data structures and functions that would be very helpful — and it would be much quicker to use those features than to re-implement them.
Put another way, the goal here is to identify what parts of the problem do not need a new solution. Reducing the amount of work you would need to do would naturally reduce the amount of code you need to write or debug, which can save a great deal of time.
1. Would the Python dictionary (dict) be helpful? If so, what would be used as a search key?
2. Would the Python list be helpful?
3. Do the Python libraries have other functions and methods that would assist in this problem? You can find out from online help, such as “help(str)” for strings.
Data Structure Design
Good data structures will greatly reduce the amount of code required. It is technically possible to write a complete program without any lists or dictionaries, but to do so would lead to a great deal of code duplication, which is difficult to maintain or to fix when there are errors.
This assignment therefore requires using these data structures, not just to demonstrate that the student knows how to do so, but to assure that the program code will be short enough to complete on time.
The following questions only pertain to those data structures that play a prominent role for the project. There is no need to list special-purpose usages that only play a minor role; and there is no need to discuss all of the other smaller variables (numbers and strings) in the project.
1. If any dictionary is used, what would be the search key, and what associated data would be retrieved from it?
2. If any list is used, what would be stored in that list?
3. Will the data structures be initialized within the program code, or from data in an input file, or will they be created and filled in while the program is running?
Functional Design
A larger program often is (or should be) divided into smaller functions to make it more manageable. The top-down design philosophy considers the big picture first and then identifies the major sub-problems to be solved, and then further divides those into smaller sub-problems, until everything is understood well enough to start implementation.
The Data Design which precedes this section helps to reduce how many functions need to be written, because the provided data structures already have useful methods to manage that data (and most of those methods would have been identified in the earlier Analysis stage)
The Functional Design will be the last phase before implementation, and will be the last phase in this particular assignment. A good plan will guarantee that the remaining time in the semester will be sufficient to complete the project, because the later assignment will only have a few ‘small’ problems to solve.
For this phase, list the functions that will need to be implemented to complete the program For each function, list all of the following:
1. A meaningful name for the function
2. One or two sentences summarizing what the function must do. (If one or two sentences are not enough, consider whether it needs to be divided into more functions)
3. A list of the parameters to the function, including:
a. the name of the parameter
b. the type of the parameter (list, string, integer, etc.)
c. whether the function is expected to modify the parameter
4. A description of the return value(s) from the function, if any. (Ideally, a function that modifies a parameter will not have any other return value)
5. Which other functions in the list that will be called by this function.
NOTE AGAIN: “Each” function. There should be multiple sets of these last answers. I expect between 2 to 5 functions designed in your solution (more would be allowed). These functions modularize some portion of the larger problem.