C++ Code Critique
You are to understand and ultimately critique the following program
which was given out as a lab a number of years ago.
Analysis
You should analyze the code above and determine the purpose of each of
the classes written (i.e., what role does it play in the program). There
are some comments currently in the code, but your analysis should go beyond
these comments. However, it should not be necessary to write more than
a paragraph for each class. In order to determine each class' role,
you should focus on how it interacts with other classes in the program
or how a particular task is accomplished. Although the classes above are
listed in no particular order (other than alphabetic), it might be useful
for you to group like classes together.
From your analysis, you should be able to answer the following questions:
- What is the relationship between a bowler and a game?
(Hint: think about how you would model a game between two bowlers versus
two games by a single bowler.)
- What is the purpose of the function Bowler::TakeTurn? What
assumptions does it make?
- What is the purpose of the class Frame?
- Why is there a vector object in the class Frame?
- What part of the code depends specifically on the 10th frame?
- Explain the frame update algorithm.
- Explain the algorithm to print out the game's scores.
Critique
You should critique the code and design of the program in terms of its
C++ style, design, and general readability. Remember, this code was intended to
be given to beginning students to extend. The program has some good
qualities, but the design and code also have some problems. You should
write approximately one page analysis of the code and design. The following
points should help guide your critique.
-
Good things about the code, that you might keep in the final version.
-
Problems with the code, things that have easy fixes but that show flaws
in use of C++ or coding in general.
-
Problems with the design. There may be immediately apparent problems with
the design of the program/class, but you may find it necessary to think
of how the program might be used in order to make pronouncements on design
flaws. A good design will facilitate changing/extending the code or using
it in new ways.
-
Any other comments are welcome.
Additionally, answer the following questions:
-
How helpful were the comments?
What would make them more helpful?
Do the comments get at the important aspects of the code?
-
The following functions are kind of long. How would you divide them up
to make them easier to understand?
PlayMatch
Stats
Game::TakeTurn
-
How would the rest of the code benefit if you added functions, IsMark, NumSpares,
and NumStrikes, to the Frame class that reported if the frame contained a mark
(either a strike or a spare), and the number of spares and strikes respectfully?
-
What is the purpose of the skill level? What is its range?
How did you find that out?
-
Does the program work as intended? How would you test it to verify it before
giving it out to novice students?
Does your answer (or the effort needed to discover the answer) to any of
the questions change your overall critique?
Comments?