About the unit
This unit is primarily about two things. First, learning the Java language, and, second, learning to produce good Object-Oriented (OO) designs for programs. The two are distinct since Java can be used in a non-OO style, and since you don't need to use Java to do OO programming, but they fit together well. However, OO design is about more than using objects: just because you're using objects doesn't mean your program is well-designed.So, again, this unit sets out to do two things: teach the Java language, and teach the principles of good OO design. These are also the aims of the text, and it is particularly good at the latter. The downside is that since you are meant to read through whole sections at a time, it is not very good as a reference book i.e., it is not so useful when you already know the subject and just want to quickly check some details. So you may find you want another book which is organised by subject (instead of by lessons) and which has a more complete coverage of the language. Also, the text only touches the surface of many subjects in order to introduce the key ideas. Other books contain far more details on almost every subject. However, the text is very good at teaching OO design and basic Java. It contains many exercises and examples which are particularly helpful and much of the unit follows the book closely. For these reasons I recommend you buy the book and study it as the unit progresses.
The core of the Java language -- in fact most of it apart from its OO features and massive libraries -- is very similar to C: the syntax is very similar, and things like for loops, conditional statements and arrays are very similar. Since you have learnt C in COMSM1201 this should make learning Java much easier. In fact you can write substantial Java programs that are very similar to equivalent C programs. However, this is a very bad idea and misses the point of Java and OO Programming. (You would also get very bad marks for submitting this kind of program.) This unit will teach you a new style of programming that will result in you writing Java programs that look very different from their equivalents in C, and have many advantages over them, for example being easier to maintain and extend. Learning this style of programming is the main objective for the first half of the unit. So although the unit teaches Java from scratch, the emphasis is more on the OO programming style and the principles of good OO design -- how and why to use the language in a certain way -- and less on the basics of the language. Similarly you should spend more time on learning the OO style of programming and OO design principles than the basics of the language.
In addition to the basics of Java and OO design, the unit covers some more advanced and specialised subjects, such as networking and GUI programming in Java, either because they are instructive case studies or significant subjects in their own right.
The unit follows an iterative approach, in which material may be (re)visited more than once. Hopefully this makes it easier to learn.
Lectures 2-10 follow the book very closely and are intended to highlight and reinforce material from them. You may find that these lectures don't add much to the handouts and book and if so feel free to skip them.
- Lectures 2-5 introduce both the basics of programming with Java and some OO concepts. They don't assume much background knowledge, but they cover a lot quickly.
- Lecture 3 introduces the key OO design concepts of cohesion and coupling and distinguishes between applications which merely function correctly and those which are also well-designed. This material is not specific to Java, but there is also some Java material in this lecture.
- Lecture 6 is about testing programs rather than about Java.
- Lecture 7 revisits the design concepts of cohesion and coupling, and introduces responsibility-driven design and refactoring. Chapter 7 is one of the best chapters in the text, and studying the examples can make these somewhat abstract concepts much clearer. The refactoring examples are excellent.
- Lectures 8, 9 and 10 return to the specifics of the Java language to cover how to use some of its key OO features: inheritance, abstract classes, and interfaces. These features are all ways of implementing the OOP concept of polymorphism, and these lectures are also about when and why to use these features.
- Lecture 11 covers Graphical User Interface (GUI) programming in Java.
Frequently Asked Questions
- Do I have to use BlueJ?
No. Use anything you like to write and compile java code. - Why do we have a class test?
It's a useful additional way of evaluating your knowledge and giving you a mark. It tests your knowledge in a different way to writing assignments. It covers a wide range of material that could not all fit into a few assignments. Finally, it tests your understanding alone whereas your friends may have helped you understand the assignments. So in summary it means the marks on the unit are more accurate than they would be using coursework only. - Why is the class test partly open book?
Because I don't think memorising things is a good use of your time, especially since you will probably forget them the week after the test. If you know enough to look up and understand the answer very quickly you know enough about the subject. No programmer in the world is expected to work without looking things up.
Material covered in each lecture
lecture 1
- about the unit
- goals
- the text and its pros and cons
- bluej: a simple IDE (Integrated Development Environment)
- programming paradigms: imperative, Object Oriented, functional, logical
- 5 key OO concepts
- objects and classes
- relation to C structures
- abstraction
- encapsulation
- polymorphism
- inheritance
- about java
- features of the language
- java virtual machine
- java APIs
- java terminology
lecture 2
chapter 1:
- basics concepts of OOP
- object
- class
- method
- parameter
- data type
- field
chapter 2:
- fields
- constructors
- overloading constructors and methods (see section 3.10 in text)
- methods
- method parameters
- assignment statements
- conditional statements
- variable scope
- variable lifetime
- accessor methods
- mutator methods
- printing strings
- local variables
- the public visibility modifier
lecture 3 chapter 3:
- class design:
- abstraction
- modularisation
- class diagrams
- object diagrams
- primitive and object types
- objects creating objects
- overloading constructors and methods (in text only)
- objects containing objects
- calling methods
lecture 4 chapter 4:
- collection classes
- arrayList
- typed collections
- importing packages
- loops
- while, for, enhanced for
- iterator objects
- typed iterators
- iterators and adding to /removing from arraylists
- arrays
- null
- retrieving objects from collections
- casting
- typed collections and iterators
lecture 5 chapter 5:
- reading class documentation
- interface vs. implementation
- importing packages
- string equality
- generating random numbers
- more collection classes
- HashMaps
- HashSets
- StringTokenizer
- javadoc
- visibility modifiers (public and private)
- information hiding
- class variables (which are called static variables in java)
- constants
lecture 6 chapter 6:
- logic errors and syntax errors
- unit testing
- test automation
- test harnesses
- walkthroughs
- debuggers
- assertions (preview of chapter 12)
lecture 7 chapter 7:
- coupling
- cohesion
- code duplication
- responsibility-driven design
- refactoring
lecture 8 chapter 8:
- inheritance
- superclasses and subclasses
- inheritance and constructors
- subtyping and substitution
- type polymorphism
- wrapper classes and autoboxing
lecture 9 chapter 9:
- method polymorphism
- static and dynamic type
- overriding
- method lookup
- super calls
- overriding toString
- protected access
lecture 10 chapter 10:
- abstract classes
- multiple inheritance
- interfaces
- interfaces as types
- interfaces as specifications

