In this chapter, I have shown how object orientation helps us minimize consequences of shifting requirements on a system and how it contrasts with functional decomposition.
I covered a number of the essential concepts in object-oriented programming and have introduced and described the primary terminology. These are essential to understanding the concepts in the rest of this book. (See Tables 1-3 and 1-4.)
Table 1-3. Object-Oriented Concepts
Concept
Review
Functional decomposition
Structured programmers usually approach program design with functional decomposition. Functional decomposition is the method of breaking down a problem into smaller and smaller functions. Each function is subdivided until it is manageable.
Changing requirements
Changing requirements are inherent to the development process. Rather than blaming users or ourselves about the seemingly impossible task of getting good and complete requirements, we should use development methods that deal with changing requirements more effectively.
Objects
Objects are defined by their responsibilities. Objects simplify the tasks of programs that use them by being responsible for themselves.
Constructors and destructors
An object has special methods that are called when it is created and deleted. These special methods are:
Constructors, which initialize or set up an object.
Destructors, which clean up an object when it is deleted.
All object-oriented languages use constructors and destructors to help manage objects.
Table 1-4. Object-Oriented Terminology
Term
Definition
Abstract class
Defines the methods and common attributes of a set of classes that are conceptually similar. Abstract classes are never instantiated.
Attribute
Data associated with an object (also called a data member).
Class
Blueprint of an object—defines the methods and data of an object of its type.
Constructor
Special method that is invoked when an object is created.
Derived class
A class that is specialized from a superclass. Contains all of the attributes and methods of the superclass but may also contain other attributes or different method implementations.
Destructor
Special method that is invoked when an object is deleted.
Encapsulation
Any kind of hiding. Objects encapsulate their data. Abstract classes encapsulate their derived concrete classes.
Functional decomposition
A method of analysis in which a problem is broken into smaller and smaller functions.
Inheritance
The way that a class is specialized, used to relate derived classes from their abstractions.
Instance
A particular object of a class.
Instantiation
The process of creating an instance of a class.
Member
Either data or method of a class.
Method
Functions that are associated with an object.
Object
An entity with responsibilities. A special, self-contained holder of both data and methods that operate on that data. An object's data are protected from external objects.
Polymorphism
The ability of related objects to implement methods that are specialized to their type.
Superclass
A class from which other classes are derived. Contains the master definitions of attributes and methods that all derived classes will use (and possibly will override).