Libraries of
reusable classes are useful in many situations, but they also have
limitations:- Complexity. In a complex system, the class hierarchies for related
classes can become extremely confusing, with many dozens or even hundreds of
classes. Unless the programmer has access to detailed documentation or some other
way of organizing the class library, it can be difficult to figure out what was
intended by the class library developers--for example, which functions call other
functions and when. It can also be difficult to figure out how to derive new
classes within the class hierarchy. The programmer has to understand a lot about
relationships among classes to make changes and additions.
- Flow of control. A program written with the aid of class libraries is
still responsible for the flow of control--that is, it must control the
interactions among all the objects created from a particular library. The
programmer has to decide which functions to call at what times for which kinds of
objects, because the library is basically passive and doesn't do anything unless
the programmer figures out how to make it happen. This can become a significant
problem in a program that involves multiple derived objects with many slightly
different kinds of data and behavior.
- Duplication of effort. Although class libraries allow programmers to
use and reuse many small pieces of code, each programmer puts those pieces
together in a different way. Two different programmers can use the same set of
class libraries to write two programs that do exactly the same thing but whose
internal structure (that is, design) may be quite different, depending on
hundreds of small decisions each programmer makes along the way. This becomes a
maintenance problem, especially for developers working on a series of related
programs. Inevitably, similar pieces of code end up doing similar things in
slightly different ways and don't work as well together as they should.
Class libraries provide lots of flexibility, but the more complex the program,
the more programmers are forced to reinvent basic solutions to basic problems
over and over again.
Frameworks, which were introduced in Chapter 1, represent the next level of
abstraction beyond class libraries. They were first developed to free application
programmers from the chores involved in displaying menus, windows, dialog boxes,
and other standard user interface elements for personal computers. Frameworks
also represent a change in the way programmers think about the interaction
between the code they write and code written by others. Figure 12 shows how this
interaction has evolved over the years.
[Contents]
[Previous]
[Next]
Addison-Wesley Publishing Company, Copyright©1995 by Sean Cotter
and Taligent,Inc. All rights
reserved.