Object-Oriented Programming

Lecture: Tuesdays, 16.15, room not yet known. Lab: Tuesdays, 18.15, room 137.

Prerequisites

One of the standard programming languages C, C++, Java, C#, and some programming experience. The course will be based mostly on C++.

Tentative Schedule

Slides

Classes are tuesday, 16.15, room 103. Exercises are tuesday, 18.15, room 137.

Exercises

Exercises are on tuesday, 16.15, room 107.

Connect Four Game

You need to understand how this game works! I discussed it in the lectures in enough detail. You need to understand the C++ constructions that were used in it. I hope that it teaches you how to write good code that has a good class design and that makes use of what the STL has to offer. When you present your final project, we will speak 30 minutes about your project, and 30 minutes about this connect four game. In your project, I want also to see high-quality, maintainable code with a well-chosen class structure. The final project is not a hacking exercise!

Final Mark

Your mark will be based on three things: The marks for points 2 and 3 will be determined when you present your project.

Some Remarks about Programming Style

Programming is Communicating

Most students seem to think that the main task of the programmer is to explain to a computer how to solve a problem. This is wrong. Nearly every program is going to be updated some day. Your task is to make the work of the person who comes after you as easy as possible. This person is not going to make you compliments for your smart tricks, he does not enjoy figuring out what f1, f2, f3 mean, and he does not like to trace your clever break statements.

What should be in a class?

This is a hard but important question. Finding the right classes requires talent and experience. There are the following type of classes:

What's in a Name?

As a general rule: Class names must be nouns (not: readinput, but inputreader). Fields of classes must be nouns. For a method that returns a boolean, it must be possible to read the name as question. (open, isinteger, greater than) Methods that return some other object should be nouns. (Not int getrandomint( ), but int random( ). Not double computesine( ), but double sine( )) Methods that have side effects must have imperative names.

What should be in a comment?

There is no need to write obvious things in a comment, only because your teacher tells you that code has to be commented. In a comment, you write what is important but not obvious. For class comments, comments about the external interface should be separated from comments about the internal implementation. Class invariants must be listed in comments. (I think most of them are internal) Preconditions of methods must be commented. Invariants of loops must be commented, when they are not obvious.