An Introduction to Object-Oriented Programming / Edition 3

An Introduction to Object-Oriented Programming / Edition 3

by Timothy Budd
ISBN-10:
0201760312
ISBN-13:
9780201760316
Pub. Date:
10/12/2001
Publisher:
Pearson Education
ISBN-10:
0201760312
ISBN-13:
9780201760316
Pub. Date:
10/12/2001
Publisher:
Pearson Education
An Introduction to Object-Oriented Programming / Edition 3

An Introduction to Object-Oriented Programming / Edition 3

by Timothy Budd
$206.65
Current price is , Original price is $206.65. You
$206.65 
  • SHIP THIS ITEM
    This item is available online through Marketplace sellers.
  • PICK UP IN STORE
    Check Availability at Nearby Stores
$181.25 
  • SHIP THIS ITEM

    Temporarily Out of Stock Online

    Please check back later for updated availability.

    • Condition: Good
    Note: Access code and/or supplemental material are not guaranteed to be included with used textbook.

This item is available online through Marketplace sellers.


Overview

In An Introduction to Object-Oriented Programming, Timothy Budd provides a language-independent presentation of object-oriented principles, such as objects, methods, inheritance (including multiple inheritance) and polymorphism. Examples are drawn from several different languages, including (among others) C++, C#, Java, CLOS, Delphi, Eiffel, Objective-C and Smalltalk. By examining many languages, the reader is better able to appreciate the general principles that lie beyond the syntax of the individual languages.


Product Details

ISBN-13: 9780201760316
Publisher: Pearson Education
Publication date: 10/12/2001
Edition description: Subsequent
Pages: 640
Product dimensions: 6.55(w) x 9.40(h) x 1.55(d)

About the Author

Timothy A. Budd is an Associate Professor of Computer Science at Oregon State University. Budd received his Bachelor of Arts degree in Mathematics and Computer Science from Western Washington University, and his masters and doctorate degrees in computer science from Yale University. His research interests include multi-paradigm programming languages, programming environments, compiler implementation and optimization techniques.



Read an Excerpt

PREFACE:

I started writing the first edition of this book in 1988, and it was finally published in the last days of 1990. The eight years between the original development of the book and the present have seen a series of changes in the field of object-oriented programming, necessitating almost a complete rewriting of the text. Among these changes are the following:

  • A better understanding of the distinction between subclasses and subtypes, and an appreciation of the fact that the two are often not the same.
  • The rapid growth, evolution and standardization of the language C++, including the introduction of templates, exceptions, name spaces, booleans, strings, the RTTI (run-time type identification system), and the standard library.
  • The introduction of the programming language Java, as an exciting new tool for developing applications for the World Wide Web.
  • The slow demise of the language Object Pascal after being abandoned by Apple as the primary language for application development on the Macintosh, only to be reborn as a new language with the same name as a tool for developing PC applications using Delphi.
  • The equally slow collapse in the use of the language Objective-C. For those interested in the study of languages this is an unfortunate loss, since the dynamically typed Objective-C is almost an ideal foil to the statically typed language C++. For this reason I have continued to discuss Objective-C in the second edition of the book.
  • The development of exciting new object-oriented languages, such as Beta, CLOS and Java, that bring both new ideas and old ideas wrapped up in new guises. The development of new waysof thinking about collections of classes that work together, resulting in the refinement of ideas such as application frameworks and design patterns.

For these reasons and many more almost every section of the second edition has been revised from the first. Nevertheless, I have attempted to retain the overall structure of the book. This structure can be described as a series of themes, somewhat as follows:

I. Introduction, Design.

Chapter 1 introduces in an informal setting the basic concepts of object-oriented programming. Chapter 2 continues this theme, by introducing the principle of designing by responsibility. These two chapters are fundamental, and their study should not be given short shrift. In particular, I strongly encourage at least one, if not several, group exercises in which CRC cards, introduced in Chapter 2, are used as a vehicle in problem solving. The manipulation of physical index cards in a group setting is one of the best techniques I have encountered for developing the notions of behavior, responsibility and encapsulation.

II. Classes, Methods and Messages.

Chapters 3 and 4 introduce the basic syntax used by our example languages (Smalltalk, C++, Java, Objective-C and Object Pascal) to create classes and methods, and to send messages. Chapter 3 concentrates on the static features (classes and methods), while Chapter 4 describes the dynamic aspects (creating objects and sending messages). Chapters 5 and 6 then reinforce these ideas with the first of a series of case studies; example programs developed in an object-oriented fashion andillustrating various features of the technique.

III. Inheritance and Software Reuse.

Chapters 7, 8 and 9 introduce the concept of inheritance, and the use of inheritance as a technique for software reuse. The case study in Chapter 8, written in the language Java, also illustrates the use of a standard API (Application Programming Interface). Chapter 9 contrasts the use of inheritance and composition as dual techniques for software reuse.

IV. Inheritance in More Detail.

The four chapters beginning with Chapter 10 delve into the concept of inheritance in greater detail. The introduction of inheritance into a programming language has an impact on almost every other aspect of the language, and these implications are often not initially obvious to the student (or programmer). Chapter 10 discusses message lookup and the binding of methods to messages, illustrating the fact that subclasses and subtypes need not be the same. Chapter 11 discusses the semantics of method overriding, pointing out two very different interpretations that are found in almost all languages. Chapter 12 continues by exploring some of the further implications of inheritance on topics such as memory allocation, assignment, and the testing for equality. Finally, Chapter 13 explores the idea of multiple inheritance.

V. Polymorphism.

Much of the power of object-oriented programming comes through the application of various forms on polymorphism. Chapter 14 introduces the basic mechanisms used for attaining polymorphism in object-oriented languages. This is followed by a pair of case studies that illustrate these points. The first, in Chapter 15, considers the creation of general purpose container libraries. A specific library, the recently developed Standard Template Library in C++, is then discussed in Chapter 16.

VI. Software Engineering.

Chapter 17 discusses a number of standard software engineering topics in the context of object-oriented languages. Chapter 18 introduces some relatively new concepts in the field of object-oriented design, the ideas of application frameworks and design patterns. Both are techniques for describing how collections of classes are used together in the solution of programming problems. Finally, Chapter 19 illustrates the design of an application framework by describing a specific example, the Little Application Framework.

VII. Advanced Topics.

The concept of classes is, on second examination, not as simple as the development in Chapter 3 would lead us to believe. Chapter 20 briefly considers a number of advanced topics in the field of object-oriented programming. Examples include the idea of delegation (object-oriented programming without classes), and metaclass programming (programming the language itself). Chapter 21 describes in general terms the variety of implementation techniques used in the execution of object-oriented languages.

In the ten-week course I teach at Oregon State University I devote approximately one week to each of the major areas described above. Students are at the same time working on moderate-sized projects using an object-oriented language of their choice, and the term ends with student presentations of their project designs and outcomes.

In the first edition of the book I concluded with a chapter title "Further Information". Unfortunately, the field moved so quickly that this information was almost immediately out of date. Rather than placing this information in the book, for the second edition I will endeavor to maintain a web site with recent information.

Obtaining the Source

Source code for the cast studies presented in the book can be accessed via anonymous ftp from the machine ftp.cs.orst.edu, in the directory /pub/budd/oopintro. This directory will also be used to maintain a number of other items, such as an errata list, study questions for each chapter, and copies of the overhead slides I use in my course. This information can also be accessed via the World Wide Web, starting from my personal home pages at ...

Table of Contents

1. Thinking Object-Orineted.


Why is OOP Popular?


Language and Thought.


A New Paradigm.


A Way of Viewing the World.


Computation as Simulation.


A Brief History.



2. Layers of Abstraction.


Layers of Abstraction.


Other Forms of Abstraction.


A Short History of Abstraction Mechanisms.



3. Object-Oriented Design.


Responsibility Implies Noninterference.


Programming in the Small and in the Large.


Why Begin with Behavior.


A Case Study in RDD.


CRC Cards-Recording Responsibility.


Components and Behavior.


Software Components.


Formalize the Interface.


Designing the Representation.


Implementing Components.


Integration of Components.


Maintenance and Evolution.



4. Classes and Methods.


Encapsulation.


Class Definitions.


Methods.


Variations on Class Themes.



5. Messages, Instances, and Initialization.


Message-Passing Syntax.


Accessing the Receiver from Within a Method.


Object Creation.


Pointers.


Memory Recovery.


Constructors.


Constant Values.


Destructors and Finalizers.


Metaclasses in Smalltalk.



6. A Case Study: The Eight Queens Puzzle.


The Eight-Queens Puzzle.


Using Generators.


The Eight-Queens Puzzle in Each Language.



7. A Case Study: A Billiards Game.


The Elements of Billiards.


Graphical Objects.


The Main Program.


Using Inheritance.



8. Inheritance and Substitution.


An Intuitive Description of Inheritance.


Subclass, Subtype, and Substitution.


Interfaces.


Forms of Inheritance.


Inheritance in Various Languages.


Inheritance and Constructors.


The Benefits of Inheritance.


The Costs of Inheritance.



9. Case Study - A Card Game.


The Class Playing Card.


Data and View Classes.


The Game.


Card Piles-Inheritance in Action.


Playing the Polymorphic Game.


The Graphical User Interface.



10. Subclasses and Subtypes.


Substitutability.


Subtypes.


The Substitutability Paradox.


Is This a Problem?


Dynamically Typed Languages.


Pre and Post-conditions.


Scandinavian Semantics.



11. Static and Dynamic Behavior.


Static versus Dynamic Typing.


Static and Dynamic Classes.


Static versus Dynamic Method Binding.



12. Implications of Substitution.


Memory Layout.


Assignment.


Copies and Clones.


Equality.



13. Multiple Inheritance.


Inheritance as Categorization.


Problems Arising from Multiple Inheritance.


Multiple Inheritance of Interfaces.


Inheritance from Common Ancestors.


Inner Classes.



14. Polymorphism and Software Reuse.


Polymorphism in Programming Languages.


Mechanisms for Software Reuse.


Efficiency and Polymorphism.


Will Widespread Software Reuse Become Reality.



15. Overloading.


Type Signature and Scopes.


Overloading Based on Scopes.


Overloading Based on Type Signatures.


Redefinition.


Polyadicity.


Multi-Methods.



16. Overriding.


Notating Overriding.


Replacement versus Refinement.


Deferred Methods.


Overriding versus Shadowing.


Covariance and Contravariance.


Variations on Overriding.



17. The Polymorphic Variable.


Simple Polymorphic Variables.


The Receiver Variable.


Downcasting.


Pure Polymorphism.



18. Generics.


Template Functions.


Template Classes.


Inheritance in Template Arguments.


Case Study-Combining Separate Classes.



19. Container Classes.


Containers in Dynamically Typed Languages.


Containers in Statically-Typed Languages.


Restricting Element Types.


Iteration.



20. A Case Study: The STL.


Iterators.


Function Objects.


Example Program-An Inventory System.


Example Program-Graphs.


A Concordance.


The Future of OOP.



21. Frameworks.


Reuse and Specialization.


Example Frameworks.



22. An Example Framework: TheAWT and Swing.


The AWT Class Hierarchy.


The Layout Manager.


Listeners.


User Interface Components.


Case Study: A Color Display.


The Swing component Library.



23. Object Interconnections.


Coupling and Cohesion.


Subclass Clients and User Clients.


Control of Access and Visibility.


Intentional Dependency.



24. Design Patterns.


Controlling Information Flow.


Describing Patterns.


Iterator.


Software Factory.


Strategy.


Singleton.


Composite.


Decorator.


The Double-Dispatching Pattern.


Flyweight.


Proxy.


Façade.


Observer.



25. Reflection and Introspection.


Mechanisms for Understanding.


Methods of Objects.


Mechanisms for Modification.


Metaclasses.



26. Network Programming.


Addresses, Ports, and Sockets.


A Simple Client/Server Program.


Multiple Clients.


Transmitting Objects over a Network.


Providing More Complexity.



27. Implementation.


Compilers and Interpreters.


The Receiver as Argument.


Inherited Methods.


Overridden Methods.


Name Encoding.


Dispatch Tables.


Bytecode Interpreters.


Just-in-Time Compilation.



A. Source for the Eight-Queens Puzzle.


Eight-Queens in Apple Object Pascal.


Eight-Queens in C++.


Eight-Queens in Java.


Eight-Queens in Objective C.


Eight-Queens in Smalltalk.



B. Source for the Billiards Game.


The Version without Inheritance.


The Verstion with Inheritance.



C. Source for the Solitaire Game.


Glossary.

Preface

I started writing the first edition of this book in 1988, and it was finally published in the last days of 1990. The eight years between the original development of the book and the present have seen a series of changes in the field of object-oriented programming, necessitating almost a complete rewriting of the text. Among these changes are the following:

  • A better understanding of the distinction between subclasses and subtypes, and an appreciation of the fact that the two are often not the same.
  • The rapid growth, evolution and standardization of the language C++, including the introduction of templates, exceptions, name spaces, booleans, strings, the RTTI (run-time type identification system), and the standard library.
  • The introduction of the programming language Java, as an exciting new tool for developing applications for the World Wide Web.
  • The slow demise of the language Object Pascal after being abandoned by Apple as the primary language for application development on the Macintosh, only to be reborn as a new language with the same name as a tool for developing PC applications using Delphi.
  • The equally slow collapse in the use of the language Objective-C. For those interested in the study of languages this is an unfortunate loss, since the dynamically typed Objective-C is almost an ideal foil to the statically typed language C++. For this reason I have continued to discuss Objective-C in the second edition of the book.
  • The development of exciting new object-oriented languages, such as Beta, CLOS and Java, that bring both new ideas and old ideas wrapped up in new guises. The development of new ways ofthinking about collections of classes that work together, resulting in the refinement of ideas such as application frameworks and design patterns.

For these reasons and many more almost every section of the second edition has been revised from the first. Nevertheless, I have attempted to retain the overall structure of the book. This structure can be described as a series of themes, somewhat as follows:

I. Introduction, Design.

Chapter 1 introduces in an informal setting the basic concepts of object-oriented programming. Chapter 2 continues this theme, by introducing the principle of designing by responsibility. These two chapters are fundamental, and their study should not be given short shrift. In particular, I strongly encourage at least one, if not several, group exercises in which CRC cards, introduced in Chapter 2, are used as a vehicle in problem solving. The manipulation of physical index cards in a group setting is one of the best techniques I have encountered for developing the notions of behavior, responsibility and encapsulation.

II. Classes, Methods and Messages.

Chapters 3 and 4 introduce the basic syntax used by our example languages (Smalltalk, C++, Java, Objective-C and Object Pascal) to create classes and methods, and to send messages. Chapter 3 concentrates on the static features (classes and methods), while Chapter 4 describes the dynamic aspects (creating objects and sending messages). Chapters 5 and 6 then reinforce these ideas with the first of a series of case studies; example programs developed in an object-oriented fashion andillustrating various features of the technique.

III. Inheritance and Software Reuse.

Chapters 7, 8 and 9 introduce the concept of inheritance, and the use of inheritance as a technique for software reuse. The case study in Chapter 8, written in the language Java, also illustrates the use of a standard API (Application Programming Interface). Chapter 9 contrasts the use of inheritance and composition as dual techniques for software reuse.

IV. Inheritance in More Detail.

The four chapters beginning with Chapter 10 delve into the concept of inheritance in greater detail. The introduction of inheritance into a programming language has an impact on almost every other aspect of the language, and these implications are often not initially obvious to the student (or programmer). Chapter 10 discusses message lookup and the binding of methods to messages, illustrating the fact that subclasses and subtypes need not be the same. Chapter 11 discusses the semantics of method overriding, pointing out two very different interpretations that are found in almost all languages. Chapter 12 continues by exploring some of the further implications of inheritance on topics such as memory allocation, assignment, and the testing for equality. Finally, Chapter 13 explores the idea of multiple inheritance.

V. Polymorphism.

Much of the power of object-oriented programming comes through the application of various forms on polymorphism. Chapter 14 introduces the basic mechanisms used for attaining polymorphism in object-oriented languages. This is followed by a pair of case studies that illustrate these points. The first, in Chapter 15, considers the creation of general purpose container libraries. A specific library, the recently developed Standard Template Library in C++, is then discussed in Chapter 16.

VI. Software Engineering.

Chapter 17 discusses a number of standard software engineering topics in the context of object-oriented languages. Chapter 18 introduces some relatively new concepts in the field of object-oriented design, the ideas of application frameworks and design patterns. Both are techniques for describing how collections of classes are used together in the solution of programming problems. Finally, Chapter 19 illustrates the design of an application framework by describing a specific example, the Little Application Framework.

VII. Advanced Topics.

The concept of classes is, on second examination, not as simple as the development in Chapter 3 would lead us to believe. Chapter 20 briefly considers a number of advanced topics in the field of object-oriented programming. Examples include the idea of delegation (object-oriented programming without classes), and metaclass programming (programming the language itself). Chapter 21 describes in general terms the variety of implementation techniques used in the execution of object-oriented languages.

In the ten-week course I teach at Oregon State University I devote approximately one week to each of the major areas described above. Students are at the same time working on moderate-sized projects using an object-oriented language of their choice, and the term ends with student presentations of their project designs and outcomes.

In the first edition of the book I concluded with a chapter title "Further Information". Unfortunately, the field moved so quickly that this information was almost immediately out of date. Rather than placing this information in the book, for the second edition I will endeavor to maintain a web site with recent information.

Obtaining the Source

Source code for the cast studies presented in the book can be accessed via anonymous ftp from the machine ftp.cs.orst.edu, in the directory /pub/budd/oopintro. This directory will also be used to maintain a number of other items, such as an errata list, study questions for each chapter, and copies of the overhead slides I use in my course. This information can also be accessed via the World Wide Web, starting from my personal home pages at http://www.cs.orst.edu/~budd/oopintro. Requests for further information can be forwarded to the electronic mail address budd@cs.orst.edu. A paper mail address is: Professor Timothy A. Budd, Department of Computer Science, Oregon State University, Corvallis, Oregon, 97331, USA.

Necessary Background

I have presented the material in this book assuming only that the reader is knowledgeable in some conventional programming language, such as Pascal or C. In my courses, the material has been used successfully at the upper-division (junior or senior) undergraduate level and at the first-year graduate-student level. In some cases (particularly in the last quarter of the book), further knowledge may be helpful, but is not assumed. For example, a studentwho has taken a course in software engineering may find some of the material in Chapter 17 more relevant, and one who has a course in compiler construction will find Chapter 21 more intelligible. On the other hand, both chapters can be simplified in presentation if necessary.

Preface to First Edition

The inspiration to write this book arose, as did that for my earlier book on Smalltalk Budd 87, when I was faced with teaching a course and was not able to find a suitable existing text. I had been for some years teaching a seminar on Smalltalk and object-oriented programming, using my own book as the text. Starting in the late 1980's, I received an increasing number of requests for a course structured around C++. About the same time, the popularity of the Macintosh computer brought with it a slightly smaller call for instruction in Object Pascal. Finally, the announcement of the NeXT computer resulted in inquiries about how best to learn Objective-C.

Since I did not wish to teach four different courses, each dealing with a specific object-oriented language, I resolved to teach a single course in which I would lay out the principles of object-oriented programming, illustrating these principles with examples from each of the four languages. Participants would learn a little about each language, and would complete a project in a language of their choice.

I then set out to find a textbook for such a course. What I discovered, to my surprise, was that existing texts, although in many ways quite admirable, were all oriented around a single language. Books I considered included Cox Cox 86, Goldberg and Robson Goldberg 83, Kaehler and Patterson Kaehler 86, Keene Keene 89, Meyer Meyer 88a, Pinson andWiener Pinson 88 and its companion, Wiener and Pinson Wiener 88, Pohl Pohl 89, and Stroustrup Stroustrup 86. Although in the end, I selected a few of these as optional texts, I rejected all of them for use as a primary text for the simple reason that each one, to a greater or lesser extent, gives the impression that "object-oriented programming" is synonymous with "object-oriented programming in X", where X is whatever programming language happens to be the author's favorite. Instead, I started writing my own lecture notes to use as a primary text. Over the course of the next year I revised and extended these notes; this book is the result.

Various participants in my course (which turned out to be much more popular, and hence much larger, than I had anticipated), in addition to projects in the four languages that I have mentioned, successfully completed projects in Actor Actor 87, Turbo Pascal Turbo 88, and CLOS Keene 89. Since my objective was to convey the principles of object-oriented programming in a language-independent manner, I inquired specifically of these individuals whether the material discussed in my lecture notes was applicable and useful in their individual work. Based on their positive response, I believe I have at least partially succeeded in achieving a measure of language independence.

This book should not be considered a substitute for either a language tutorial or a language reference manual for any of the four languages discussed. In each of the languages,there are numerous subtle but language-specific or implementation-specific features that I did not believe were relevant to the discussions in this text, but that are certainly important as practical matters to the programmer.

Acknowledgments

I am certainly grateful to the 65 students in CS589 at Oregon State University who, in the fall of 1989, suffered through the development of the first draft of this text. They received one chapter at a time, often only a day or two before I would lecture on the material. Their patience in this regard is appreciated. Their specific comments, corrections, critiques and criticisms were most helpful. In particular, I wish to acknowledge the detailed comments provided by Thomas Amoth, Kim Drongesen, Frank Griswold, Rajeev Pandey, and Phil Ruder.

The solitaire game developed in Chapter 8 was inspired by the project completed by Kim Drongesen, and the billiards game in Chapter 6 was based on the project completed by Guenter Mamier and Dietrich Wettschereck. In both cases, however, the code itself has been entirely rewritten and is my own. In fact, in both cases my code is considerably stripped down, for the purposes of exposition, and is in no way comparable to the greatly superior projects completed by those students.

I am also grateful to those people who provided comments, corrections, critiques, and criticisms on subsequent drafts of the manuscript. These individuals include Michael Adar, Jerrie Andreas, Brad Cox, Graham Dumpleton, Peter Grogono, Nola Hague, Marcia Horton, Ralph Johnson, Doug Lea, Ted Lewis, Stanley Lippman, Darcy McCallum, Lindsay Marshall, Makku Sakkinen, Michael Share, Dave Taenzer, Nabil Zamel, several reviewers,including Ed Gehringer, James Heliotis, Karl Lieberherr, Jeff Parker, Justin Smith, and Daniel Sterms and Keith Wollman, my editor at Addison-Wesley.

The source listings were printed using Latex macros based on C program formatting macros originally written by Eamonn McManus, of Trinity College, Dublin.

For an author it is always useful to have others provide an independent perspective on ones work, and I admit to gaining some useful insights into the first edition from a study guide prepared by Ms. K. Brintz, Ms. L. Leenen, Mr. T.A. Meyer, Ms. J.A. Rosenblatt and Mrs. A.P. Viljoen of the Department of Computer Science and Information Systems in the University of South Africa, in Pretoria, South Africa.

Countless people have provided assistance by pointing out errors or omissions in the first edition, and describing improvements. I am grateful to them all, and sorry I cannot name more people here.

For the second edition my capable, competent, and patient editors at Addison-Wesley have been Lynne Doran-Cote and Deborah Lafferty.



From the B&N Reads Blog

Customer Reviews