The trouble with test questions

One of my students complained to me about the questions on a test once. The question in question came from a previous Advanced Placement Computer Science exam. The complaint was that the code in the question was bad. It was bad because no one in their right mind would write a program like it. It went about things in an unnecessarily complex way. Unnecessarily that is if your goal was efficient, easy to read and easy to maintain code. The student was right. He went on to state that the AP CS program was full of how not to do things. Again, in a way at least, he was right.

The problem is that often on a test you are trying to demonstrate something in a small number of lines of code or you are testing a student’s ability to understand the operation of a concept. Sometimes you have to bend the rules about good design to force things into a small but complete demonstration.

The problem for students is that they just see a small but complex program doing something that could be very simple to do. They want to jump in and “fix” the program. Teachers see the concept they are trying to teach but students just see artificial code. It’s a tough problem. It is also one of the reasons the AP CS curriculum has a complex case study – it lets students see a good design on a reasonably sized project. If only we could do more of that.

I was thinking about all of this while reading a blog by Dan Forhan the other day. He has an example of a Java puzzle that is some very convoluted code.  One would never write a program like that to produce the output that puzzle produces. Well not if you intended people to actually use it you wouldn’t. It’s just not the write way to do it.

At the same time you might very well right code that has 20 times as many lines but the same organization of  classes and methods all calling each other. You’d no doubt be trying to solve a more complex problem than a bunch of System.out.println statements of course. If a student can’t follow the simple (ok simple here is a relative term) example in the puzzle how will they ever follow a more complex problem?

One tool that they could use though is a good debugger that will let them step through the code statement by statement. I think that many times teachers ignore the value of a debugger as a means for demonstrating the path the computer takes through a program. Debuggers can show the program flow, how and where the values in variables are changed and many other things that are not always obvious when checking code on paper. I liked to show the steps through the debugger using an LCD projector on a white board or screen in class. Sometimes seeing is believing.

Comments (1)

  1. Daniel Forhan says:

    Hi Alfred,

    Regarding your refernce to my example, posted orignally by Dr. Heinz M. Kabutz, ( I just wanted to clarify this for you. It is a puzzle, not a teaching example. Challenging puzzles hardly ever make a whole lot of sense. I had a professor once who would often challenged us with puzzles like this one as well as other logic puzzles. It was what he called "brain exercise". I often use puzzles with my class to challenge students. The kids love it! I didn’t however show them the one you are referring to. That was more for the Java teachers/programmers out there (for entertainment purposes only). 🙂


Skip to main content