Skip to main content

Imperative Programming II:  2013-2014

Lecturer

Degrees

Preliminary ExaminationsComputer Science and Philosophy

Preliminary ExaminationsComputer Science

Preliminary ExaminationsMathematics and Computer Science

Term

Overview

This course starts with an introduction to the basic concepts and techniques of modular program construction and Object-Oriented Programming (OOP). It continues with modest-sized case-studies that introduce some of the basic OOP programming idioms in realistic settings.

There are three main ideas: encapsulation, that programs should be built from objects that satisfy a coherent specification and hide the details of how that specification is implemented; object identity, that each object has a distinct identity, so that multiple objects can co-exist and interact with each other; and polymorphism, that objects that implement the same interface can be used interchangeably to give a variety of behaviours.

There is a correspondingly heavy use of practicals to develop understanding of OOP in general, and the use of Scala in particular.

Learning outcomes

After studying this course, undergraduates will be able to:

  • Develop Scala programs with multiple classes that follow the principles of objected-oriented programming.
  • Organise multiple related classes using appropriate inheritance mechanisms, such as traits and abstract class, and basic design patterns.
  • Use generics to develop polymorphic programs, and explain the differences among generics, subtyping polymorphism and operator overloading.
  • Read and modify medium-sized objected-oriented programs.
  • Use the Collection/Iterator framework and explain the cons and pros of the underlying design principles of the framework.

Synopsis

1: Objects, Classes and Inheritance (Lectures 1 - 6)
  • Introduction. Reminder of the Scala language. Objects and functions in Scala.
  • Inheritance. Subtyping. Overriding. Dynamic dispatch. Encapsulation.
  • Traits and mix-in. Linearization. Stackable modification.
  • Pattern matching. Extractors.
  • Circuit simulation example. Simultaneous use of functional and imperative features.

2: Polymorphism and Advanced Types (Lectures 7 - 12)

  • Three types of polymorphisms in Scala: generics, overloading and subtyping. Covariance and contravariance.
  • Abstract members and abstract types.
  • Implicit conversions and parameters.

3: Collections (Lectures 13 - 16)

  • Programming with the Scala Collections library. Iterators. 
  • Design of the Scala Collections library.

Syllabus

Language features for structuring classes in Object-Oriented Programming: inheritance, abstract class, dynamic binding, and mix-ins (traits in Scala). Three kinds of polymorphism in OOP: subtyping polymorphism, overloading, and generics. Basic design patterns. Case studies: circuit simulation and collection framework with associated iterators.

Reading list

We recommend the following book:

  • Martin Odersky, Lex Spoon and Bill Venners, Programming in Scala, 2nd edition, artima.

This book, the lecture slides and occasional references from the slides will form good reading materials for this course.

If students want to go deep into the materials covered, they will find the following books useful:

  • Barbara Liskov and John Guttag, Program Development in Java, Addison-Wesley.
  • Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, Design Patterns:  Elements of Reusable Object-Oriented Software, Addison-Wesley.
  • Peter Sestoft, Java Precisely, 2nd edition, MIT Press.

The first book was the recommended text of this course before the 2012/2013 academic year. Although the course was changed, Chapters 1-10 of the book are still relevant to the lectures. The second book is a well-known reference on design patterns, which all OOP developers should know eventually. The last has a good description of language features of Java. Scala is often used together with Java, so this book will be useful when students build or modify real-world Scala programs.

Feedback

Students are formally asked for feedback at the end of the course. Students can also submit feedback at any point here. Feedback received here will go to the Head of Academic Administration, and will be dealt with confidentially when being passed on further. All feedback is welcome.

Taking our courses

This form is not to be used by students studying for a degree in the Department of Computer Science, or for Visiting Students who are registered for Computer Science courses

Other matriculated University of Oxford students who are interested in taking this, or other, courses in the Department of Computer Science, must complete this online form by 17.00 on Friday of 0th week of term in which the course is taught. Late requests, and requests sent by email, will not be considered. All requests must be approved by the relevant Computer Science departmental committee and can only be submitted using this form.