Compaq Reliable Transaction Router Network Router User Manual


 
Object-Oriented Programming
Table 2–1 Functional and Object-Oriented Programming
Compared
Functional Programming Object-Oriented Programming
A program consists of data
structures and algorithms.
A program consists of a team of
cooperating objects.
The basic programming
unit is the function, that
when run, implements an
algorithm.
The basic programming
unit is the class, that when
instantiated, implements an
object.
Functions operate on
elemental data types or
data structures.
Objects communicate by sending
messages.
An application’s architecture
consists of a hierarchy of
functions and sub-functions.
An applications architecture
consists of objects that model
entities of the problem domain.
Objects’ relationships can vary.
Objects
In the object-oriented environment, a program or application
is a grouping of cooperating objects. The basic programming
unit is the class. Instantiating, or declaring an instance of,
a class implements an object. RTR provides object-oriented
programming capabilities with the C++ API, described in the
C++ Foundation Classes manual. Objects are instances of a
class. In a transaction class, each transaction is an object. An
object is an instantiated (declared) class. Its state and behavior
are determined by the attributes and methods defined in the
class. An object or class is defined by its:
State (attributes)
Behavior (methods)
Identity (name at instantiation)
The name given at object declaration is its identity. In
Example 2–1, the two dog objects King and Fifi are instances
of Dog. The Dog class is declared in a header (Dog.h) file and
implemented in a .cpp file.
Architectural Concepts 2–7