Programming with Class: A Practical Introduction to Object Oriented Programming with C++
The table of contents given below includes links to additional materials. Some complete chapters, and various subsections, are available either as Postscript files or directly readable "html" text.
Section 1: Introduction to Object Oriented Programming
Introduction to Object-oriented Programming
-
Why adopt Object Oriented Programming?
- Problems with conventional programming styles: The low productivity of development programmers* The maintenance programmers*Disjoint processes for "Analysis", "Design" and "Implementation"* Software costs*
- The source of the problems: The original specification pervades the code* Meyer's topless program* The problems of top-down design*
- Saved by "modular programming"? Programming with modules* Exploiting "generic" packages*
- Limitations of "modular programming"? Changing the software to meet a change in specification:* "The standard library modules is never what I need"* Meyer's modules that are simultaneously "Closed" and "Open":*
- Object Oriented Programming: Inheritance and Dynamic Binding: Inheritance* Dynamic dispatch of function calls*
- An OO example
- Consistency of model: Analysis-Design-Implementation
- Why adopt OOP?
References
- A History of OO programming
- Simula
- Smalltalk
- The Artificial Intelligentsia: Actors, Frames, and OO extensions to Lisp
- Objective C
- Apple's Pascal dialects: Classcal and Object Pascal
- C++
- Eiffel
- References
Exercises
- How OO Languages Work, (Postscript source)
- "SpaceInvaders": An example program that uses objects
- Classes: defining the structure and behaviour of objects
- Defining class hierarchies
- Access controls and inheritance
- Forms for class hierarchies that use single inheritance
- Multiple Inheritance: Class hierarchies as Directed Acyclic Graphs (DAGs)* Name conflicts with multiple inheritance* Ambiguities with repeated inheritance* Realistic applications of multiple inheritance*
- Summary on Declaring the Structures of Objects
- Creating instances of classes
- Representation of Objects, and Code for Classes, in Memory
- Methods have an implicit object reference parameter
- Exploiting polymorphism in a program's structure
- Explicit support for abstract classes
- Summary on the Definition and Use of Objects
- Extended OO features: "generic" or "parameterized" classes
- Extended OO features: Automatic Garbage Collection
- Extended OO features? Exception handling
- Extended OO features: Assertions
References
Section 2: Introduction to theuse of C++ as an Object Oriented Implementation Language.
Introduction to C++
- C++ : minor extensions to C
- Comments
- Function Prototypes
- Default arguments for functions
- Automatic type coercions
- const declarations
- Inline function definitions
- Types void and void*
- Declarations of enumerated types and structs
- Declarations/definitions as statements
- Reference types
- New dynamic store manipulations
- Scope qualifier operator
- Stream Input and Output
References.
- Programmer Defined Data Types in C++
- Simple Types: Points and Rectangles: C++ Class Declaration* Definition of member functions* Class as the unit of protection* Constructors* Overloaded member functions* Simple version of class Point* Enhancing class Point: inline functions improve efficiency* Constant instances of programmer defined types* Operator functions* Constructors as type conversion functions* Stream I/O with programmer defined types* Friend functions* Class Rectangle* Initializing component objects* Using an enumerated type defined by a class* const data members* Examples of stream I/O functions for Point and Rectangle
- A class with resource management responsibilities Memory leaks and "destructors"* Dangling pointers and class specific assignment operators* Classes with separately allocated data members* Class "String"
- Watching a program work: side-effects of constructors and destructors
- A "cluster" of related classes: LinkedList and friends Class LinkedList* Planning interactions among objects* Class LinkedList: Implementation details* Class Link* Class LinkedListIterator* Enhancement of the LinkedList class cluster*
- Assoc: a class "employing a subcontractor"
- Data characterising a class and shared by all its instances
- Summary on "Programmer Defined Types"
References
- C++: Inheritance and virtual functions
- Strict Inheritance: extending an existing class
- Planning for extension: "Protected Access"
- Planning for extension: "Virtual Functions" Replacing an inherited behaviour* Static or dynamic binding for member functions* A standard form for a base class*
- "private" inheritance
- Class LinkedList and friends revisited A Design for class Item and its Subclasses* Extended LinkedList class
- Example: SpaceInvaders
- Example: Operating System Simulation The Assignment* Finding the objects and their classes* Design and Implementation detail*
Exercises
Section 3: Tools and Class Libraries
Exploiting Reusable Code
- Development Tools and Libraries
- Class Libraries Component libraries* Graphics User Interface Libraries* Framework libraries
- Class browsers
- Debugging aids
- Development Environments
References
- Simple Use of a Framework Class Library, (Postscript source)
- Framework Class Libraries The problem domain addressed by framework libraries* Handling a user's commands* Example frameworks*
- Display Structures
- Cards program
- Cards: Analysis and Design A data model for the Cards program* A display structure for the Cards program* Application and Document classes* Some scenarios for object interactions*
- Detailed design A Data model for Cards* Views for Cards*
- Implementations
- Additional Features of Framework Class Libraries
- Command Objects The role of command objects* Simple command objects that handle menu commands* Command objects that handle mouse-based editing actions* Commands that add data* More advanced uses of Command objects*
- Object I/O The representation of objects in memory and in files* Transferring heterogeneous collections to/from files* Framework support for input and output of objects*
- The cloning of Objects
- "Dependencies"
- Using the command-handler chain
- An Example "Editor" Program
- The :Finite State Machine (FSM)" program
- FSM: Analysis The principal objects* Analyzing interactions among objects* Classes and responsibilities resulting from the analysis*
- Some design decisions
- Implementations
Exercise
-
Section 4: Intermediate topics
Intermediate Topics
- OO Developments. From Analysis, through Design,to Implementation
, (text in readable html)
- Analysis
- Design: From Blobs to Boxes Firming up the classes and identifying additional classes* Identifying class hierarchies* Using class libraries* Documenting the design*
- Detailed design: Have you covered É?
- Implementation:
- Generalizing to create a new class library?
- Benefits?
References
- Intermediate C++
- Template functions
- Template Classes Class Buffer: a simple template class* Class LinkedList and friends (again)* Class Bintree*
- Nested Classes
- Access and Inheritance revisited
- Multiple Inheritance Inheriting interfaces or combining "types"* Inheriting from partially implemented and concrete classes*
- Exceptions
References
- Eiffel
- Introduction Origins of Eiffel* Inheritance in Eiffel* A complete system - language plus standard class libraries and support tools*
- Classes
- Objects
- Features
- Functions and procedures
- Statements and Control structures
- Inheritance
- A simple example
- Assertions
- Exception handling
- "Once"
- "Holes" in the type system?
- Example The "assignment" - a chase game* Finding the objects and their classes* Implementation
- Postscript
(Macintosh disk associated with book)
Of possible related interest is a tutorial on the use of Symantec's Think Class Library.
Last modified March 1996. Please email questions to
nabg@cs.uow.edu.au