Information/Guide for the Midterm Exam
to be held Thursday, August 20th
The exam will focus on the relation between the code we are working with for the phone system and the object-oriented design principles discussed in Meyer's book. The exam will also test your understanding of the C++ constructs and organization used in the code.
To get the "easiest" part out of the way first, you should study all of the code in the PS2 system that is on-line and make sure you understand the syntax in detail. It is often not too hard to copy and adapt some code, as you did in your PA2, but I want to be sure you actually understand the operation of the C++ code. Therefore, as you work through the code, if there is any part of it that you do not completely understand, be sure you study the relevant sections of the Lippman and Lajoie C++ Primer so you do understand it.
Here's an example: Should the following appear in a header file or a .cp file:
int Connector::next_id = 0;
The answer is that this is the initialization of a static member variable ("slot") which must appear only once. Therefore it cannot be in a header file that might be included in numerous .cp files and lead to errors at link time. It must be in a .cp file. (In the PS2 project it is in the link.cp file.)
Another example might involve some code that shows a collection of slots in various classes, each of which contain an instance of one of the other classes, e.g.,
A my_a; // an instance of class A here.
This can be very difficult to arrange because each such slot needs to be preceded by a full definition of the other class, in this case A. This cross-referencing problem is immediately solved by using slots that are pointers to class instances, e.g.,
A* my_a; // a pointer to an instance of class A here.
This works if there are merely forward declarations available, in this case,
class A;
Other topics you should master include member initialization lists, how constructors are called in practice, Boolean operators, chains of references, e.g.,
connector->out->packet = ...
or notations such as,
if (!pickup_timer->is_on()) ...
One thing to know well is the design and implementation of the Timer class.
I have explained in class that you should read Chapters 1 through 10 of Meyer using a "top-down" strategy. Your general approach (there will be exceptions) is to do the following:
For each chapter:
Read the first couple of pages and then the "Key Concepts" section near the end.
Then make another pass through the ten chapters doing this:
Read each item in the light blue/gray highlight boxes, plus a paragraph or two around the box to understand it in context.
Then make a third pass:
For any items that appear important and relevant to our work in the class, read a modest amount of additional material to clarify your understanding of what Meyer is saying.
For your final pass:
For each distinct type of structure or strategy in the PS2 phone system design and code, find the part(s) of Meyer's discussion that motivates and explains the approach. What you're often looking for is information spread over two or three files, not just code snippets.
Questions that will appear on the Midterm:
The questions about the material I will ask will involve matching principles I give you and code I give you and writing a brief and concise short paragraph or two about the relation between our design and code and the principles of design laid out in Meyer's book.
The list below gives you some guidance as to what to look for in each chapter and especially, how much emphasis to place on each chapter, or what points in each you should pay particular attention to. Pay attention to the fact that Meyer's terminology is not always identical to what is used in C++, e.g., "feature" describes both member variables (slots) and member functions (methods).