CPSC 231: Common Design Issues
These are some of the design problems and pitfalls that the
markers saw when they were marking the second assignment this term:
- (Inappropriate) use of global variables. Move them as local variables
inside of specific drawing functions (if the variables only store information
specific to that drawing function)
- Some functions (especially "main()"
were way over 15 lines of code ...[TA's comment: and some weren't just
slightly over 15 lines, some were closer to 50 lines]). Decomposing the
drawing code into parts (additional functions) would have been one way to
shorten the length of functions.
- Improper use of nested functions (e.g. functions definitions inside of
other functions... for no reason) [JT's note: we actually didn't talk about
defining functions within other functions this term because their use is
confined to specialized applications so if this is the first time that you
have heard of such a concept don't be concerned].
- I found were that people didn't understand what it meant to put all their
code into functions. A lot of students put most of their code into a function,
but left out important things that should be a part of a function (like the
test for the size of the image). Alongside this issue, students also did not
understand that they should be passing variables into their functions, not
just calling on variables that were within the scope of the functions.
- Not laying out their program in the proper order. There are certain
things that should be at the top of your program: imports, creation of
constants. [JT's note: this goes back to what we talked about in lecture,
before you can use something (e.g., constant) it first has to be created.
Because you will need constants in your program instructions you should
typically define what they are before any of the instructions in your program].
- [JT: not really a design issue but it's worth mentioning that students
missed this because it is important] lack of documentation / commenting