CSE143 Notes for Monday, 3/31/08

Mostly I went over the syllabus (handout #1) which can be found on the class web page.

I started by pointing out that in the first two assignments we will be reviewing arrays and classes. It would be especially helpful to review chapters 7 (arrays) and 8 (classes) of the textbook as we work through this material.

I spent a few minutes reviewing some basic terminology of object-oriented programming. I asked, "What is an object?" and got some good responses. Most people remembered that there are two primary aspects of an object: some data stored in variables and some methods that act on that data. I mentioned that the following is a good summary of the basic object idea:

An object encapsulates state and behavior.
The terms state and behavior are the technical terms we use, but they are the same ideas people had mentioned. For example, for a radio, the states would include on/off, volume setting, station setting, am/fm and so on. The behavior is that it plays music and that it allows us to change these settings. In programming, state usually means variables (data) and behavior usually means methods.

I then mentioned an idea that I got from Arthur Riel who has written a book on object-oriented design heuristics. Following Riel's advice, I asked everyone in the audience who knows how to use a radio to raise their hand. All the hands went up. Then I asked people to raise their hand if they know how to build a radio from low-level electronic parts. Fewer than 5% of the class raised their hand. This is an important distinction to understand. We all know how to use a radio, but only some of us know how to build one.

In programming, we refer to this as the "client" view and the "implementation" or "implementor" view. Another way of thinking of this is that the external/client view is the "what" part (knowing what the object does) and the internal/implementation view is the "how" part (knowing how the object does it). This is going to be an important concept to understand as we progress through cse143. One of the things that makes this more confusing in cse143 is that we will ask you to switch back and forth between these two views, implementing an object at the same time that you think about how it will be manipulated from the outside by a client.


Stuart Reges
Last modified: Mon Mar 31 15:50:14 PDT 2008