This
chapter attempts to give you a feel for the broad issues of object-oriented
programming and C++, including why OOP is different, and why C++ in particular
is different, concepts of OOP methodologies, and finally the kinds of issues
you will encounter when moving your own company to OOP and C++.
OOP
and C++ may not be for everyone. It’s important to evaluate your own
needs and decide whether C++ will optimally satisfy those needs, or if you
might be better off with another programming system. If you know that your
needs will be very specialized for the foreseeable future and if you have
specific constraints that may not be satisfied by C++, then you owe it to
yourself to investigate the alternatives. Even if you eventually choose C++ as
your language, you’ll at least understand what the options were and have
a clear vision of why you took that direction.
You
know what a procedural program looks like: data definitions and function calls.
To find the meaning of such a program you have to work a little, looking
through the function calls and low-level concepts to create a model in your
mind. This is the reason we need intermediate representations when designing
procedural programs – by themselves, these programs tend to be confusing
because the terms of expression are oriented more toward the computer than the
problem you’re solving.
Because
C++ adds many new concepts to the C language, your natural assumption may be
that, of course, the
main( )
in a C++ program will be far more complicated than the equivalent C program.
Here, you’ll be pleasantly surprised: A well-written C++ program is
generally far simpler and much easier to understand than the equivalent C
program. What you’ll see are the definitions of the objects that
represent concepts in your problem space (rather than the issues of the
computer representation) and messages sent to those objects to represent the
activities in that space. One of the delights of object-oriented programming is
that, with a well-designed program, it’s very easy to understand the code
by reading it. Usually there’s a lot less code, as well, because many of
your problems will be solved by reusing existing library code.