荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: BlueBoy (蓝孩), 信区: Program
标  题: The Essence of Object-Oriented Programming 2
发信站: BBS 荔园晨风站 (Sat Mar 25 08:43:13 2000), 转信

[Table of Contents] [Previous] [Next] [Object Central Home]

The Essence of Object-Oriented Programming

Copyright ? 1998, Bruce E. Wampler

    1.1  Introduction
    1.2  Object Orientation
    1.3  Object-Oriented Languages
    1.4  The Essence of OO and C++
    1.5  The Payoff of Objects
    1.6  A Case Study
    1.7  The Rest of the Book



--------------------------------------------------------------------------------


Chapter 1
Let's Talk Objects

1.1  Introduction
This book is about object-oriented software development. Object-oriented
development is more than simply writing some code in C++, Java, or Eiffel, but
includes the complete process - analysis of the problem, design of a solution,
coding, and finally
long term maintenance. Object orientation1 has the potential for huge
productivity gains, but only if it is used as part of a complete process.
Object orientation requires a fundamental change in the way you think about
developing programs. Before you
can understand and effectively use the OO development process, you must first
understand objects and object-oriented design.

If you check out your local bookstore's computer book section, or read some of
the latest programming journals, you might get the impression that OO means
programming in C++ or Java. While this is not untrue, it is only part of the
story. The rest
includes Object-Orientvelopment process really needs OOA and OOD. Developing an
OO system directly in C++ without first going through the OOA and OOD steps is
like building a house without first analyzing the requirements of the house,
designing it,
and producing a set of blueprints. You might end up with a roof over your head,
but the rooms would likely be scattered all over the place, some rooms might be
missing, and the whole thing would probably come tumbling down on your head
during the first
storm (Figure 1.1). A C++ program built without OOA and OOD might seem to work,
but it is much more likely to be full of bugs, and break when you make the
first modification.


1.2  Object Orientation
Objects are the heart of object orientation. An object is a representation of
almost anything you need to model in a program. An object can be a model of an
employee, a representation of a sensor, a window in a user interface, a data
structure such as
a list, virtually anything. One way to think of an object is as a black box
with some butthe object to do what you need, and what the lights mean about the
status of the object. The details of how the box is put together inside are
irrelevant while you
are using the box. A software object is not much different. It has well-defined
methods for interacting with the outside world, and can provide information
about its current state. The internal representation, algorithms, and data
structures are hidden
from the outside world.





Figure 1.2: A black box.

In the simplest terms, designing an OO system consists of identifying what
objects the system contains, the behaviors of the objects, and how the objects
interact with each other. One of the most neatest things about OO software
development is that
this simple methodology connects and integrates the analysis, design, and
programming phases of the development process.

Object-oriented development is a major advance for software development.
Although it may not be a magic bullet that solves all the problems associated
with producing software, it is really better that older methodologies. While
other development
methodologies, such as structured design and programming, have many valid
points, many which carry over and are used for OO development, the different
phases of the development cycle have nC++, Objective C, Objective Pascal, Java,
and even Ada. There
are two clear marketplace winners, C++ and Java.

For many reasons, C++ is the emerging winner as the OO language of choice for
major native applications. Probably the main reason is that it was derived from
C, and thus has a heritage of being able to do real things on real systems.
There is also
compatibility with existing C code.

Java is also increasing in popularity, mostly due to the incredible expansion
of the World Wide Web. Because of the ever increasing importance of the Web, it
seems likely that the number of Java applications will exceed that of C++
before too long.\

However, this book will concentrate on using C++ whenever a real language is
needed as a reference for object-oriented ideas. Future versions will probably
concentrate more on Java. Almost all of the principles discussed here will
apply equally to C++
and Java.

There are a couple of very important points to remember about C++. It is true
that you can use C++ as a ``bet++ to implement objects, and not on all the
syntactic sugar available with the language.


1.4  The Essence of OO and C++
There are several different object-oriented development methodologies in use
today3. Each has its strengths and weaknesses, and, unfortunately, each has its
own notation. It is possible, however, to extract the essence of the different
OOA and OOD
methodologies, and summarize them quite concisely. This book covers OOA and OOD
using a simplified version of the Coad-Yourdon methodology, which is one of
most straightforward of the bunch.

Learning C++ can be a rather difficult experience. By first getting a good
understanding of that basics of objects, OOA, and OOD, learning C++ becomes a
much more manageable task. By approaching C++ with an understanding of objects,
you will be able to
use the essential core of C++ the way it was intended, to build objects. You
can focus on how to use C++ to implement objects instead of being lost in the
vast forest of its syntactic detail.

This is not to say that all the extra features of C++ are useless, because they
are not. They can get in the way as you are first learning the language.
Eventually, as you build more objects, the reason for some of the other
features of C++ will become
evident.


1.5  The Payof beginning coding, many software projects have managed to get by
without them. Analysis and design are much more critical for successful OO
projects.

Once you begin coding, there are other front-end costs, especially with C++.
First, there is some tedious overhead code that must be implemented for every
object4. Each object is also typically implemented as two separate files, so
you end up with many
short files to keep track of. This leads to some often boring front-end efforts
that you must slog through to get to a working system.

In the end, however, the payoff is huge. First, an object-oriented design is
likely to be simple and easy to understand. Once designed, you can often
implement the objects separately. Once finished, each object tends to be robust
and bug free. As you
make changes to the system, existing objects continue to work. And as you
improve existing objects, their interface to the world stays the same, so the
whole system continues to work. It is this ease of change and robustness that
r. It is covered by
the GNU Library Public License, so you can use the code for yourself under the
terms of the license.


1.7  The Rest of the Book
Eventually, this book will be organized into three parts. The first part, which
is mostly complete now, covers objects. Objects and classes are defined. Then
the basics of Coad-Yourdon object-oriented analysis and design are covered.

After you have read part one to get an understanding of objects, you will be
ready for part two, which will cover C++ when it gets finished. After
explaining the basics, it will cover in some depth how to use C++ to build
objects.

The third section will be a case study of V GUI library. The evolution and
design of V will be covered, followed by an examination of the C++ code. The
complete source of V is available at the Object Central web site.



--------------------------------------------------------------------------------
[Table of Contents] [Previous] [Next] [Object Central Home]
Visits:




------------------------------

--
※ 来源:·BBS 荔园晨风站 bbs.szu.edu.cn·[FROM: 192.168.0.90]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店