Object-Oriented (OO) technology is becoming one of the most important
technologies in software development. It has enormous potential for significantly
increasing programmer productivity and code maintainability.[1-3]
Why is OO gaining such a widespread acceptance among commercial software
developers and large corporations? Procedural code of industrial strength
(thousands of lines of code) is often unstable under small perturbations,
e.g., trying to fix a single problem might create five new ones[2,3]
When the code size is larger than some threshold (about 10^5 lines of code),
procedural techniques appear to break down: design and implementation complexity
makes projects quite difficult and expensive, and eventually maintenance
cost dominates development cost[2,3]
Object-Oriented techniques promise to allow more stable and larger applications
(several millions and tens of millions of lines of code) to be built[1-3]
How can it be done? Why should a natural scientist care?
Natural scientists model and simulate natural phenomena. Computers simulate
"real" (e.g., balancing a checkbook, mimicking the behavior of
a physical system,...) and "imaginary" (e.g., games) worlds.
Rapid advances in hardware and software are making possible the treatment
of interesting and complex systems (e.g., turbulent flows, critical dynamics,
lattice quantum chromodynamics, weather prediction, cellular metabolism,
social phenomena,...). Simula, a language that pioneered object-oriented
technology was specially conceived for simulations. Hence, it is not surprising
that object-oriented programming may make simulation and visualization
of complex phenomena easier than procedural techniques (e.g., Fortran).
For fully exploring models of complex systems, displaying results and data
in a powerful manner (e.g., scientific visualization, multimedia, virtual
reality,...), for enhancing collaboration fully exploiting networking facilities,
OO technology appears better suited than procedural languages.
The principle "divide and conquer" has been known for a long
time as an efficient technique to conquer large empires (e.g., large codes).
But, how to divide? Both procedural and OO programming employ the principle.The
fundamental difference between these two models is the choice of building
blocks. In procedural programming, procedures are the fundamental units
(usually called subroutines or subprograms). In the object model, basic
units are "cells" or "atoms" called objects which contain
both data (i.e., state variables associated with the "atom" state
at a given time) and methods (i.e., dynamical rules, rules that explain
how "atoms" interact in the outside world). In OO terminology,
objects encapsulate data and behavior. These objects are individual weakly
interacting blocks. Objects interact (exchange messages) to produce collective
behavior.
OO views the word as composed of objects with well-defined properties.
Object dynamics is pictured as interaction among objects. Interactions
are mediated by messages that objects exchange with each other. In fact,
for a physicist this description may sound familiar as it resembles our
modern view of the atomic and subatomic world. This suggests that we could
expect interesting analogies between Quantum Physics (QP) and the object
model (OM). These analogies are identified and exploited in this work to
present an introduction to the OO philosophy. Our examples use C++ as it
currently is the most widely used OO language.[4].
The main goal of this work is to provide an introduction to OO concepts
for an audience of natural scientists and graduate/advanced undergraduate
students in the Physical Sciences. We introduce some of the main OO ideas
in this work at three different levels. At the highest level, we discuss
general OO concepts, independent of the language. At an intermediate level,
and to produce more concrete examples, we express some of the QP concepts[5]
in the C++ language. [C++ code is written in this style, and adopts
the Taligent notational style[6]]. Usually,
in this process we select a particular C++ design, the simplest to illustrate
some OO features. Selected designs rarely are the "best" and
usually oversimplify the physics. Thus, the code provided in this work
is mainly for didactic purposes and not intended for a real project.
Section II presents some basic concepts
in the object model (OM): abstraction, encapsulation, modularity and hierarchy.
They are illustrated with examples from the atomic/subatomic world. Connections
between the OM and some concepts in Quantum Physics are presented in Section
III. Table 1, at the end of that
section, summarizes some of these analogies. Section
IV discusses additional analogies between structures in quantum physics
and constructs in the object model, and then summarizes them in Table
2. Dynamics in the OM and in QP are discussed and contrasted in Section
V. Section VI introduces the problem of
object-oriented design of a complex system. Analogies between hypermedia
and the path integral formulation of QP are presented in Section
VII. Finally, the last section collects
some final thoughts and summarizes some of the experiences of earlier scientific
users of the object-oriented technology.