An Introduction to Object-Oriented Programming

By Timothy Budd

Study Guide for Chapter 6


Learning Objectives

After reading this chapter, you should be able to:

Note that there are few new technical ideas presented in this chapter. Rather, the intent of the case study is to simply illustrate once again how it is possible to structure a computer program in such a way that the flow of execution is controlled and directed by a set of interacting software components.


Study Questions

You may wish to use the print or save as command on your web browser to produce a copy of this study guide. That way you can fill in the answers to the questions as part of your assimilating the information you learn in this chapter.
  1. Give some examples of how the design makes holes, walls, and balls responsible for their own behavior.

  2. By making each graphical object into a separate class, and making each responsible for a different aspect of behavior, the object-oriented design is able to support a great deal of information hiding. This, in turn, leads to programs which are consierably easier to modify than when conventional techniques are used. To illustrate this, explain what sections of code would need to be modifed to produce each of the following changes:

  3. Once you have learned about inheritance (next chapter) you may wish to return to this case study. We could have made the classes Hole, Wall and Ball all subclasses of a common parent class, say GraphicalObject. We could then have factored out the common link and region fields into the parent class, as well as some of the common methods. Finally, doing so would have permitted us to maintain a single common list of graphical objects, rather than separate lists for walls, balls and holes. Explain how this would then have simplified some of the methods in this application.

Contents copyright Timothy Budd, 1995.