Course pages 2011–12
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 complete handout as provided in Lecture 1.
- Lecture 1 annotated slides (imperative basics, call stack)
- Lecture 2 annotated slides (call stack, references, function arguments, Java and the JVM).
- Lecture 3 annotated slides (Modularity, Code Re-use, Encapsulation, Immutable types) and the Vector2D example code
- Lecture 4 annotated slides (Inheritance, Shadowing, Overriding, Polymorphism) and the bouncing ball code
- Lecture 5 annotated slides (Polymorphism examples, Abstract classes, Multiple inheritance, Interfaces) and the drawing example code
- Lecture 6 annotated slides (Constructors, destructors, garbage collection, static and exceptions)
- Lecture 7 annotated slides (Cloning objects, Java Collections [Lecture cut short by power loss to building]) and the cloning example code
- Lecture 8 annotated slides (Generics, Collections, Comparisons) and the Collections example code; the Generics example code; and the Comparisons example code.
- Lecture 9 annotated Comparator slides and annotated Design Pattern Slides (Comparators, Design Patterns: Decorator, State, Strategy) and Java examples of Decorator, State and Strategy.
- Lecture 10 annotated slides (Design Patterns: Composite, Singleton, Proxy, Observer) and Java examples of Composite, Singleton,Proxy, and Observer.
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
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:
- 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.
- 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.