What are the effects of non-object-oriented design – HP Integrity NonStop H-Series User Manual
Page 15
![background image](/manuals/396950/15/background.png)
Click on the banner to return to the user guide home page.
©Copyright 1996 Rogue Wave Software
What are the Effects of Non-Object-Oriented
Design?
The STL portion of the Standard C++ Library was purposely designed with an architecture that
is not object-oriented. This design has side effects, some advantageous, and some not, that
developers must be aware of as they investigate how to most effectively use the library. We'll
discuss a few of them here.
Smaller Source Code
There are approximately fifty different algorithms in the STL, and about a dozen major
data structures. This separation has the effect of reducing the size of source code, and
decreasing some of the risk that similar activities will have dissimilar interfaces. Were it
not for this separation, for example, each of the algorithms would have to be
re-implemented in each of the different data structures, requiring several hundred more
member functions than are found in the present scheme.
●
Flexibility
One advantage of the separation of algorithms from data structures is that such
algorithms can be used with conventional C++ pointers and arrays. Because C++ arrays
are not objects, algorithms encapsulated within a class hierarchy seldom have this ability.
●
Efficiency
The STL in particular, and the Standard C++ Library in general, provide a low-level,
"nuts and bolts" approach to developing C++ applications. This low-level approach can
be useful when specific programs require an emphasis on efficient coding and speed of
execution.
●
Iterators: Mismatches and Invalidations
The Standard C++ Library data structures use pointer-like objects called iterators to
describe the contents of a container. (These are described in detail in
the library's architecture, it is not possible to verify that these iterator elements are
matched; i.e., that they are derived from the same container. Using (either intentionally or
by accident) a beginning iterator from one container with an ending iterator from another
is a recipe for certain disaster.
●