Computer Laboratory

Course pages 2011–12

Object-Oriented Programming

Handouts and Code

For the one-sheet summary of functional vs imperative programming given out in Lecture 3, please use this link.

Annotated slides for the lectures are here:

The Abstract Factory Pattern

I ran out of time to cover this in the end, so it can be seen as non-examinable material. Nonetheless, it's useful to know and you should be able to get all you need from reading the notes to do question 45 if you wish. However, note that the general pattern at the end of the notes is wrong - the corrected version is here and in the Lecture 10 notes above. If you'd like to see some code for it, look here.

Lecture 11: The Breakout clone

OK, so this lecture didn't wuite get as far as I had hoped, but I think it served to demonstrate some facets of real development. You can download the full working code if you'd like to look through it in more detail (sorry, it's not coded but feel free to email me with any questions you have). Note the use of the composite pattern on the Block class and the Observer throughout to send events to various things. You can also see the sketched notes from the lecture here

Examples Sheet

The examples sheet is available to download. Consult your supervisor to get a suitable subset of the questions to tackle.


Quite a few changes to the slides and examples sheet occured this year and inevitably there are errors in both. Please let me know if you spot any - the ones I have so far are:


  • I was sloppy when preparing the functional vs imperative text. I meant that section to be "ML vs Java" and therefore some of my comments don't generalise. For example, I said that types must be explicitly given in an imperative language. This isn't true - I meant in Java. Just look at Javascript or python if you want to see imperative languages where you can avoid specifying type for some variables.
  • Some of the Call Stack slides have a function double() which won't compile because double is a reserved keyword in Java. Replace double() with doub() or some such.
  • Some of the slides with exception handling have missing "new" keywords. When you throw an exception, that exception is an object of some Exception-inheriting class. Therefore we need to create an object to throw. Usually this is done inline: "throw new MyException()". You can also create the object before the throw: "MyException x = new MyException(); throw x;". But you need the "new" to ensure an object is created so "throw MyException()" (as some of the slides say) is wrong.
  • Slide "The Heap" should say for (int j=0;...
  • Slide "Passing Procedure Arguments in C" should be C++ (!)
  • Slide "References and Pointers". A reference DOES represent a memory address so the top right entry should be "Yes".
  • First slide on p.14 - the stack in the middle of the 2nd row has "a=200" at the top which should either be "d=200" or just "200"
  • Second paragraph on p.17. "If we can to resize our array..." -> "If we want to resize..."
  • Top paragraph on p.20. Needs a bracket to close the phrase "(using the new keyword)"
  • Third paragraph on p.20."...that that..." -> "that"
  • The Abstract Factory general pattern is wrong in the printed notes! See the annotated notes above for the correct version.

Examples Sheet

  • None reported yet...

Sample Tripos Questions

I have started to produce a few sample exam questions for the course since it's a recent addition to the IA CST lineup.

At the end of the course I will put up the solutions to these samples.