Course pages 2014–15
No. of lectures: 12
Suggested hours of supervisions: 4
Companion practical course: Programming in Java
This course runs in parallel with the Programming in Java practical course. It is intended to provide both an introduction to Java that complements the practical workbooks and to highlight the abstract notion of object-oriented programming. Examples and discussions will use Java primarily, but other languages may be used to illustrate specific points where appropriate.
- Types, Objects and Classes Moving from functional to imperative. Distinguishing state and behaviour. Primitive types. Function prototypes. Objects and classes as custom types. Introduction to parameterised types (templates/Generics).
- Pointers, References and Memory Pointers and references. The call stack and heap. Iteration and recursion. Pass-by-value and pass-by-reference. Objects as reference types in Java.
- Creating Classes Modularity. Encapsulation. Information hiding. Access modifiers. Advantages of immutability. Creating Generic types in Java. Static data.
- Inheritance Inheritance. Casting. Shadowing. Overloading. Overriding. Abstract Methods and Classes.
- Polymorphism and Multiple Inheritance Polymorphism in ML and Java. Multiple inheritance. Interfaces in Java.
- Lifecycle of an Object Constructors and chaining. Destructors. Finalizers. Garbage Collection. Copying Objects. Shallow and deep copies. Copy constructors. Cloning in Java. Cloneable as a marker interface in Java.
- Java Collections Java Collection interface. Key classes. Collections class. Iteration options and the use of Iterator.
- Object Comparison Comparing primitive and reference types. Equals. Comparable and Comparator in Java. Operator Overloading.
- Error Handling Limitations of return values. Exceptions. Custom exceptions.
- Design Patterns Introduction to design patterns. Examples of Singleton, Decorator, State, Strategy, Observer.
- Case Studies and Worked Examples
At the end of the course students should
- understand the principles of OOP;
- be able to demonstrate good object-oriented programming skills in Java;
- understand the capabilities and limitations of Java;
- be able to describe, recognise, apply and implement selected design patterns in Java;
- be familiar with common errors in Java and its associated libraries.
No single text book covers all of the topics in this course. For those new to OOP, the best introductions are usually found in the introductory programming texts for OOP languages (such as Java, python or C++). Look for those that are for people new to programming rather than those that are designed for programmers transitioning between languages (the Deitel book is highlighted for this reason). The web is also a very useful resource -- look for Java tutorials.
* Deitel, H.M. & Deitel, P.J. (2009). Java: How to Program. Prentice Hall (8th ed.).
Flanagan, D. (2005). Java in a nutshell : a desktop quick reference. O’Reilly (5th ed.).
Flanagan, D. (2004). Java examples in a nutshell : a tutorial companion to Java in a nutshell. O’Reilly (3rd ed.).
Gamma, E., Helm, R., Johnson, R. & Vlissides, A. (1995). Design patterns: elements of reusable object-oriented software. Addison-Wesley.
Bloch, J. & Gafter, N. (2005). Java puzzlers. Addison-Wesley.