Identified problem
The Seven Steps Step 5:
Translate to code
Step 6:
Test
program
A Technique for Translation from Problem to Code (1) Work an
instance
(2) Write down
exactly what
(3) Generalize
your steps
(4) Test
your
Implementation
problem
yourself from (2)
you just did steps Program
Program is
Andrew Hilton, Genevieve Lipp, and Susan Rodger Step 7:
Debug
incorrect
appears
correct
Duke University, ECE and CS Departments program
Can’t find pattern Algorithmic
[email protected],
[email protected],
[email protected] problem Success!
ing a source of domain knowledge, while remedying (b) requires obtaining Step 6: Test
Problem and Goal clarification on the problem.
Novice programmers often struggle to take a problem statement and turn
Step 6 is to test the program, by running actual test cases on the code. If a
it into working code [1, 2]. This struggle arises from the need to both devise
Step 2: Write Down What You Did test case fails, students proceed to Step 7. If no test cases fail (and the stu-
an algorithm to solve a class of problems, as well as to turn that algorithm
dent has sufficient test cases to convince themself that the code is correct),
into working code. The second step is to write down precisely what was done in Step 1. The they declare success and are done.
Several factors contribute to these difficulties: most common way for novice programmers to get stuck at this step is to say
• Students focus on memorization, not problem solving. “I just did it—I don’t know how.” In such a situation, they should work a
• Students lack a problem solving methodology. slightly more complex example where the solution is not immediately ap-
parent.
Step 7: Debug
• Finished examples do not show the process. Another common problem in this step is that students omit instructions Step 7 is to debug failed test cases. We teach debugging as an application
Our goal is to provide students with a methodology they can follow from and/or write ambiguous directions. Such mistakes do not cause a student of the scientific method. Debugging will either identify a problem with the
problem statement to working code. In particular, such a methodology to get stuck here, but they cause problems that show up in Step 4. These underlying algorithm (in which case students should return to Step 3), or
should: problems are what instructors teach about with the common “Peanut Butter with the translation to code (in which case students should return to Step 5).
• Recognize that students may struggle and provide direction for how and Jelly” activity.
to proceed in such a case. Uses and Results
Step 3: Generalize We use The Seven Steps extensively in ECE 551, as well as two Cours-
• Work on any programming problem.
era specializations. CS 101 has begun to adopt the approach based on the
• Focus on problem solving and algorithm development. In Step 3, the student should generalize from the specific values they used successes observed in these courses. One CS 101 student sent the following
• Include testing and debugging. in Step 1 to any values of the parameters. This step involves several com- e-mail about The Seven Steps:
ponents, such as generalizing specific values, naming values, identifying
The Seven Steps repetition, and making “almost repetitive” steps into uniform steps. I just want to tell you that I tried the seven step method, and I worked
Students who get stuck here should repeat Steps 1 and 2 with different pa- on all of my code for one or two hours before I even looked at the com-
We call our methodology The Seven Steps, as it is a seven-step process
rameters to help see the pattern. We also encourage students to split their puter. AND IT WORKED! I got all my code right on the first try! For
for students to follow. The diagram in the upper-right corner shows these
generalization into specific questions, and to make tables to identify pat- the first time ever, I don’t have to go to the help lab for hours on end. I
steps at a high level.
terns. just wanted to tell you how satisfied I am. Yay! Have a good day and
We note that this step is the hardest and that we explicitly tell students this thank you for re-teaching me the strategy.
Step 1: Work an Example is the hardest part when we introduce the process. A learner in one of our Coursera specializations wrote:
The first step is to work one instance of the problem by hand. The I have been programming for couple of years. Learned from so many
student should not try to generalize to all possible parameter val- Step 4: Test by Hand resources but none said how to write the algorithm, they just say you
ues at this point—they should simply solve one particular instance. Step 4 is to test your algorithm by hand. Students should pick different val- should write your algorithm first. The steps illustrated here are beauti-
ues for the parameters that were not used in Steps 1–3 and execute their ful and definitely help to understand how to decompose a problem.
For example, if the problem statement is algorithm step by step with pencil and paper. If the answer is incorrect, they
“Write a program that, given a set of points should revisit their generalization from Step 3. References
S and a point P , finds the point in S that [1] Raymond Lister, Elizabeth S. Adams, Sue Fitzgerald, William Fone, John Hamer, Morten Lindholm,
is closet to P ,” then a student should se- Robert McCartney, Jan Erik Moström, Kate Sanders, Otto Seppälä, Beth Simon, and Lynda Thomas. A
lect a particular set S (e.g., {(2, 7), (10, 5), Step 5: Translate to Code multi-national study of reading and tracing skills in novice programmers, an iticse 2004 working group
report. SIGCSE Bulletin, 36(4):119–150, December 2004.
(8, −2), (7, −6), (−3, −5), (−8, 0), (−5, 6)}) Now students are ready to translate their algorithm into code. Any step that
and a particular point P (e.g. (1, −1)). is too complex to translate into one or two statements should become its own [2] Michael McCracken, Vicki Almstrum, Danny Diaz, Mark Guzdial, Dianne Hagan, Yifat Ben-David Ko-
likant, Cary Laxer, Lynda Thomas, Ian Utting, , and Tadeusz Wilusz. A multi-national, multi-institutional
If a student cannot do this step, then either (a) they lack domain knowledge function: students repeat the Seven Steps for that function and call it in this study of assessment of programming skills of first-year cs students, an iticse 2001 working group report.
or (b) the problem is not stated clearly. Remedying (a) requires consult- algorithm. SIGCSE Bulletin, 33(4):125–140, December 2001.