HP (Hewlett-Packard) 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 HP
Reliable Transaction Router C++ Foundation Classes manual and
the Java API, described in the JRTR Getting Started 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 dened in the class. An object or class is dened 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 Fi are instances
of Dog. The Dog class is declared in a header (Dog.h) le and
implemented in a .cpp le.
2–8 Architectural Concepts