Object-Oriented Programming (Programowanie Obiektowe)
Lecture: Tuesdays, 14-16, room 140.
Lab: Tuesdays, 16-18, room 137.
Course Description
The course will be based on Unix and C++. I do not plan to discuss all
features of all object-oriented programming languages that have existed
in history. Instead I will base the course on my experience with writing
theorem provers and a flight simulation program. I will not simply
list all features of C++, but explain how they must be used. C++ is
a complicated language with many features which are often used incorrectly.
Linux
A professional computer scientist must be familiar
with Linux. Windows is designed in such a way that the user has
no control over the computer. Because of this, a Windows user never
knows where his files are, which processes are
running and what they are doing.
Windows compilers are usually integrated into development tools
and usually do not respect the standard. A Windows user is usually
not able to start an editor, and format code by himself.
Literature
-
Cplusplus.com
has very good descriptions of library functions.
-
The C++ Programming Language, Bjarne Stroustrup,
Addison-Wesley, 14th printing, 2001.
-
C++ Primer, Stanley B. Lippman, Josee Lojoie,
Addision-Wesley, November 1999.
Prerequisites
You should know C, and have some minimal programming experience.
Planned Schedule
-
08.03.2011.
Basics of linux. Editing. What is inside a file? What is a directory?
What is the difference between an executable file and a text file?
Slides .
-
08.03.2011.
How to edit and compile a HelloWorld program.
Usage of Make.
Some basic commands of C++, reading and writing input.
Declaring variables. Scopes.
Slides .
-
15.03.2011.
References, pointers and values. The notion of constness
and why it is important.
Parameter passing in functions and methods, either by reference
or by value. Allocating and freeing heap memory.
How to test for memory leaks using the top command.
-
22.03.2011.
How to design a class.
The main operators.
This is file stack.cpp that we wrote
in class.
Slides .
-
29.03.2011. Usage of constructors/destructors
for heap management. The two main models for
heap management (enforcing uniqueness and sharing with
reference counting.)
Other examples of usage of constructor/destructor.
(backtracking, file closing.)
-
05.04.2011.
How to write a program in different files. Distinction
between .h and .cpp file. How to use make on a program
that consists of different files.
These are the slides.
After that, I will demonstrate the usage of operator definitions
on a simple class that deals with rational numbers.
-
12.04.2011.
Practical aspects of class implemention: Static fields, friendship,
anonymous namespace and operator definitions. See previous week for the
slides.
The standard template library: vectors and lists.
How to use iterators. Difference between
iterator and const_iterator.
These are the slides about STL.
-
19.04.2011.
How to use std::map. Difficulties between std::map< > and
classes that have no default constructor.
If there is time left, I speak about priority queues.
-
26.04.2011. No teaching.
-
03.05.2011.
Even more no teaching
.
-
10.05.2011.
Inheritance in C++.
-
17.05.2011. Lecture cancalled, because of faculty barbecue.
-
24.05.2011.
Inheritance, these
are the slides.
-
31.05.2011.
Polymorphic Programming with Templates.
Designing your own containers using templates.
Creating partial objects. (These are objects that
either exist or do not exist.)
-
06.06.2011.
More about templates. Difficulties with
template classes and befriended methods.
This is the implementation
of the class partial< typename X > that we developed in class, and
these are the slides about templates.
-
13.06.2011.
We start with a couple of separate topics: How would you implement
a hashmap in C++?
This is what we came up with until now.
Some remarks about exercise nr11 about a polymorphic impementation of
Runge Kutta methods. Rest of the time I speak about smart pointers.
(Unique pointers, sharing pointers, variants of reference counting,
aggressive sharing.)
Upon rethinking, the example that I showed in class (string with COW)
was not so good, because it was not a template.
This is a full implementation
as template.
-
14.06.2011.
Since the rector decided that this is groundhog day, it
is still tuesday.
It is also the last lecture of the course.
The topic will probably be design patterns
(visitors, object factories, multimethods)
This is an
example with visitors
based on exercise number 9.
Grading and Project
The total number of points in the exercises is 192.
I will give maximally 100 points for the project.
This means that the project should have a complexity of approximately six
exercises in order to get the maximal number of points.
The project must contain a couple of classes in multiple files,
(correctly distributed over .h and .cpp files), it must be
compiled with a correctly prepared makefile under Linux.
The project must use either inheritance or templates.
The code must have a reasonable lay out,
see the rules.
Points are as follows:
At least 272 gives 5.0,
at least 252 gives 4.5,
at least 232 gives 4.0,
at least 212 gives 3.5, and
at least 192 gives 3.0.
In order to obtain a grade at all, one has to show at least 2/3 of exercise
points before 24.06.2011.
Exercises
Exercises are on tuesday, 16.15, room 137.