Object-Oriented Thinking

 < Day Day Up > 



Up to now, with the exception of the last two sections, all the material in this book has been presented from a procedural programming perspective. I did this deliberately, for as a C++ programmer, even though you will make the intellectual leap to thinking in objects, you eventually have to implement your member functions, which ultimately means putting one line of source code after another.

I took this pedagogical approach because if you are completely new to programming, or are approaching C++ with a procedural programming background, learning the syntax and the semantics of the language, while at the same time having classes and objects forced upon you, makes for a steep learning curve. But now, all that is behind you. You are here, reading this paragraph. You have learned the basics of the language. You know how to write procedurally oriented programs in C++ and are ready for more excitement — ready to make the jump to object speed! I’m ready if you are ready, so let us start with a whole new vocabulary. It is time for you to learn object speak!

Object Speak: A New Vocabulary

A change in thinking requires a vocabulary of new words with which you can express the wonderful new thoughts you will soon have about the design and operation of programs. The following list will get you started. I have used some of them in this and previous chapters in a subliminal attempt to alter your thought processes. These words are testable:

Table 10-2: Object-Oriented Terminology

Term

Definition

Class

This word has several meanings. Primarily, the word class denotes a set of objects that share common structure and behavior. A class declaration introduces a new user-defined data type and specifies the structure and behavior of objects of that type.

Abstract Base Class

A class that contains one or more pure virtual functions. An abstract base class serves to publish an interface. There can be no instance of an abstract base class.

Base Class

A class whose functionality is inherited by another class. A base class might be the most generalized class in a class inheritance hierarchy, but usually the term base class is applied to the immediate class from which a derived class inherits its functionality. In object-oriented design, general class functional characteristics are implemented in a base class with the intention of making this general class functionality available for inheritance.

Superclass

Another term for base class.

Inheritance

The act of adopting the behavior of a particular class of objects by another class of objects.

Derived Class

A class that inherits functionality from one or more base classes.

Subclass

Another term for derived class.

Object

This term has several meanings. The term object fundamentally means a region of memory. When a variable of a particular type is declared, a region of memory is set aside for the storage of its contents. Every object created resides in a different region of memory. In the case of complex user-defined class types, the memory regions occupied by class objects may be large compared to fundamental data types like char, int, and float. The term object is also used when you picture the interaction between object-oriented components in your mind. This is an example of reducing the concept of an object to its most abstract form. An object in this sense is a component in a complex system that interacts with other objects.

Interface

A publicly accessible set of functions intended to be the authorized way to access an object’s functionality. In some cases, direct access to data members is provided. Doing so violates the concept of data encapsulation.

Sending a message
to an object

Calling one of an object’s interface functions. When one object sends a message to another object, the sender is simply calling one of several possible interface functions available for use in the target object. The object sending the message is said to be the client while the object receiving the message is said to be the server.

Invoking a method
on an object

Calling one of an object’s interface functions.

Object-Oriented
Analysis & Design

The act of designing software in terms of objects and their interfaces. Ideally, all that you need to know about an object-oriented software application to understand its operation at a conceptual level is the objects that comprise it and their public interfaces. The details are left to the implementation.

Data Encapsulation

The act of shielding class data members from public access by declaring them private. A class’s data members should not be shared horizontally or vertically, meaning they should not be made available to objects of another class, as in a client server relationship, nor should they be shared via inheritance.

Virtual Function

A function declared in a base class that can be overridden in a derived class.

This list of object-oriented vocabulary will grow as you progress through the remaining chapters of this book.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net