Exam 1

What did I do this past week? I studied for the OOP exam and took the OOP exam. I watched the Vice Presidential debate. I had an interview. There’s only a couple of companies left on my radar; one of which has offered to fly me out again in a few weeks. Which means I’ll have to miss another quiz. Sorry Professor.

What’s in my way? I’ve got a government exam coming up next week that I need to study for. And of course, the usual weekly readings.

What will I do next week? More “busywork” - studying, interviewing maybe, and managing more student organization events. My magical crystal ball tells me we’re getting a new OOP project soon, so I bet that will be my top priority.

One of the design “philosophies” we discussed in class was:

write algorithms that demand the  WEAKEST   iterator
write containers that provide the STRONGEST iterator

When practicing for the exam, I was careful to follow these rules, writing algorithms that were slightly more verbose (by about 3 lines worth) than they needed to be for the sake of only using operators provided by weaker iterators. I was then surprised to find one of the questions on our exam was to write a function that required a random access iterator. As I had practiced a very similar problem, I knew the weakest iterator we could get away with (and still have good performance) was bidirectional. I would have to intentionally impair what I had in mind to meet the requirement.

Turns out, the next question asked for the same algorithm using a bidirectional iterator, so my practice did pay off. Even so, it felt backwards to write a solution using the strongest iterator available when we were taught to use the weakest.

A better question, I think, would have avoided any iterator strength requirement whatsoever, leaving the student to decide what was reasonable. Certainly there’s a risk of a student getting stuck trying to conjure up an input iterator solution (which I don’t believe is possible to do efficiently), but the one-pass requirement should quickly deny these attempts.

The final question on the exam also troubled me a little. We were supposed to write a container using an iterator that we had wrote in the previous problem. The requirements were obviously different, and the problem itself was testing a different set of knowledge. Writing the extra code for the container and calling the relevant iterator constructors was straightforward, but it wasn’t clear whether or not the iterator code from the previous problem was “available for use”.

Should I have written my container assuming the iterator class was already available and worked perfectly? The container question was clearly indepenent of the iterator question, so perhaps it was possible for a student to get one right and not the other. Or maybe the container was dependent on our iterator code. Should I have then copied and pasted my iterator code into the container code? Wouldn’t that mean losing points twice in two problems if I had written my iterator incorrectly? I’d also have to change my iterator code in two places rather than one, should I choose to update it.

I ultimately decided to leave out my code for the iterator class so my container code could stand alone (which would still compile, so long as the iterator was defined elsewhere). But now I realize I might lose points for not writing the iterator as an inner class. But the question was asking about the container, not the iterator, and their separate questions indicate that they’d be graded separately. I suppose I’ll find out my grade - and the “correct” approach - soon enough.

Overall though, I thought the exam was fair, well balanced, and was generously timed. I don’t have any more complaints, other than Canvas perhaps. Manual indentation isn’t exciting at all.

Tip of the Week: Normally you don’t want to commit executables and other temporary files generated by compiling your project. Instead of adding these files manually to .gitignore, try out this script that automatically adds all untracked files to .gitignore. This makes it easy to hide all the files you don’t want tracked from git in one step, so you can go back to the good old lazy git add ..

Written on October 8, 2016