📄 the oo design process1.mht
字号:
ml#resources">Resources</A></FONT></TD></TR>
<TR>
<TD class=3Dtoc> <A=20
=
href=3D"http://www-106.ibm.com/developerworks/library/oo-design1/index.ht=
ml#author">About=20
the author</A></FONT></TD></TR>
<TR>
<TD bgColor=3D#0033cc height=3D5><IMG height=3D1=20
=
src=3D"http://www-106.ibm.com/developerworks/images/c.gif"=20
width=3D120></TD></TR></TBODY></TABLE></P><!-- End =
Table of Contents -->
<BLOCKQUOTE>
<P>Welcome to the first installment of this online class. =
My=20
intent with this column is to provide a detailed =
experience in the=20
object-oriented (OO) design and development process by =
actually=20
having you do it. This column is more of a journey than an =
event,=20
as it will take months to get through the entire process. =
We'll=20
start out with requirements gathering, move through =
analysis to=20
design, then do a Java implementation of that design. When =
we're=20
finished, you'll have a complete case history of an OO =
program,=20
literally from start to finish. I'll talk a lot about the=20
underlying theory, but the central focus will be real =
examples of=20
how that theory is applied.</P></BLOCKQUOTE>
<P></P>
<P>Before we get started in earnest next month, I've a few =
warnings,=20
comments, and observations that will give you a feel for my =
own=20
prejudices and opinions on the subject of design.</P><A =
name=3D1>
<P><STRONG class=3Dsubhead>OO isn't about structure</STRONG> =
<BR>First, at its core, object orientation is not at all =
about=20
derivation, class hierarchies, UML, Java technology, and so =
forth.=20
These are tools that the OO designer puts to use in order to =
structure the analysis, the design, and the implementation, =
but they=20
aren't central to what makes an OO program object-oriented. =
I'll=20
certainly use all of these structural parts of object =
orientation as=20
the process unfolds, but the first few columns in particular =
may=20
seem mysterious to you if you equate implementation =
structure with=20
object orientation. The key concept of object orientation is =
<I>modeling</I>, so before we can do anything, we have to =
decide=20
what we're going to model. Adele Goldberg (in <I>Succeeding =
with=20
Objects</I>, see <A=20
=
href=3D"http://www-106.ibm.com/developerworks/library/oo-design1/index.ht=
ml#resources">Resources</A>)=20
recounts a story told to the congregation by a rabbi at the =
start of=20
a new year:=20
<BLOCKQUOTE>A rabbi boarded a train, one on which he often =
rode=20
and one whose conductor, therefore, recognized him. The =
rabbi=20
reached into his coat pocket for his ticket. Not finding =
it, he=20
began a search of his belongings. The conductor stopped =
him:=20
"Rabbi, I know you must have the ticket somewhere. Don't =
bother=20
searching now. You can send it later, when you do find =
it." But=20
the rabbi kept searching. When approached by the conductor =
yet=20
again, the rabbi replied: "You do not understand. I know =
you trust=20
me for the ticket, but -- where am I going?</BLOCKQUOTE>
<P>All too many projects fail because they begin without a =
clear=20
idea of where they're going. The OO process tries to solve =
this=20
dilemma by defining the problem to be solved as its first =
step; it=20
will take me a few columns to do that in sufficient detail =
so that=20
the actual analysis and design phase can proceed. That is, =
before=20
you can analyze, you have to have something <I>to</I> =
analyze.</P><A=20
name=3D2>
<P><STRONG class=3Dsubhead>Feel free to customize</STRONG> =
<BR>Next,=20
the process I'm describing is the one that I use personally. =
I don't=20
intend these articles to be definitive. It turns out that =
the way=20
that I work is similar to Booch, Rumbaugh, and Jacobsen's =
RUP=20
(Rational Unified Process, see <A=20
=
href=3D"http://www-106.ibm.com/developerworks/library/oo-design1/index.ht=
ml#resources">Resources</A>),=20
but that's not due to any planning on my part. Things just =
worked=20
out that way. I also lean in the direction of Kent Beck's =
so-called=20
Extreme Programming (XP, see <A=20
=
href=3D"http://www-106.ibm.com/developerworks/library/oo-design1/index.ht=
ml#resources">Resources</A>)=20
but again, this is just a matter of chance. I'd expect that =
my=20
processes will have to be personalized by you to make them =
workable.=20
Given that the literature is singularly devoid of a hands-on =
discussion of any process whatsoever, it seems that a =
discussion of=20
any process, even if it's a personal one, will be helpful. =
Please=20
don't spend time contemplating whether I'm "right" or not; =
just bear=20
in mind that what I do works for me, and that there's =
absolutely=20
nothing wrong with changing what I do in a way that works =
better for=20
you. <A name=3D3>
<P><STRONG class=3Dsubhead>Tools, or the lack =
thereof</STRONG> <BR>A=20
note on OO-design tools is also in order. Someone once told =
me that=20
he couldn't do OO because he couldn't afford it: "Rose costs =
$2500/seat and you obviously can't do design without Rose!" =
The=20
"Rose" in question is an OO CASE (Computer-Aided Software=20
Engineering) tool sold by Rational Software. (I may review =
OO-CASE=20
tools in a future column.) Putting aside the fact that Rose =
is=20
neither the most cost-effective, nor the most capable, nor =
the most=20
usable of the tools available, I often work effectively with =
nothing=20
more hi-tech than a pencil and paper -- no computer at =
all.</P>
<P>As we'll see in upcoming columns, the process of OO =
design is=20
really a form of semantic analysis. It has more in common =
with=20
formal linguistics than traditional procedural-design =
techniques.=20
I've found that computers often get in the way of this =
analysis. You=20
spend more time fooling around with the tool than you spend =
getting=20
work done. To make matters worse, many of these tools (Rose =
among=20
them) are tied to hideous, draconian license managers that =
prevent=20
you from running the tool on a laptop that's not connected =
via a=20
network to the license manager. When I use a computer at =
all, I=20
typically use a drawing program (Visio), not a CASE tool. =
(Which is=20
not to say that I think that Visio is a particularly good =
tool for=20
this purpose, either. I just happen to own a copy. I use my =
own=20
templates -- see <A=20
=
href=3D"http://www-106.ibm.com/developerworks/library/oo-design1/index.ht=
ml#resources">Resources</A>=20
-- not the built-in UML support.)</P>
<P>The point I'm making is that design has nothing to do =
with tools.=20
Design is a way to crystallize your own thinking on complex =
topics,=20
it's a way to make sure that you've covered as many bases as =
possible before you start to code, and it's a way to =
communicate=20
with other programmers about the code.</P>
<P>Since communication is really central here, any tool that =
doesn't=20
facilitate communication is virtually worthless. You are not =
communicating if you are sitting alone in your office in =
front of a=20
computer-based CASE tool.</P>
<P>The choice of a CASE tool is irrelevant. I don't use any =
of them=20
on a regular basis, though they can be helpful with larger =
projects.=20
The downside is that they all generate miserable code, so I =
don't=20
use the code-generation or "round-trip engineering" features =
of=20
these tools. In any event, the notion of round-trip =
engineering --=20
in which you create a design, generate code, hack up the =
code, then=20
reverse-engineer the hack back into a "design" is a =
fundamentally=20
flawed notion. Design is inherently a one-way process. You =
design,=20
then implement from the design. You modify the design, then=20
implement the modifications. Most of these tools create =
incorrect=20
designs in any event, because they can't adequately reverse =
engineer=20
the dynamic behavior of the program simply by looking at the =
code.</P>
<P>A decent drawing program and a word processor are more =
than=20
sufficient for our purposes.</P><A name=3D4>
<P><STRONG class=3Dsubhead>The design environment and =
tools</STRONG>=20
<BR>Design is always a group activity. At a minimum, you'll =
need a=20
programmer, a tester, a customer (or somebody who =
understands the=20
domain of the problem thoroughly), somebody who writes =
English=20
excellently, and a UI designer. You'll ideally have some =
sort of=20
clerical support as well: people to take notes and create=20
transcripts, to enter hand sketches into drawing programs, =
and so=20
on. You can get by without this level of support, of course, =
but the=20
design will come together more slowly since the team members =
won't=20
be able to focus.</P>
<P>All of these people have to be together to work =
effectively, and=20
all of them have to be present all the time. Design is a =
full-time=20
activity and nobody can afford to be distracted by other =
activities=20
if you expect to finish in a timely fashion. (Virtual =
togetherness,=20
using white-board software and the like, is a possibility, =
but=20
you'll need video and audio feeds so you can see and hear =
everybody=20
else, as well as the computer, if you expect to communicate=20
effectively.)</P>
<P>One of the best design tools you can have is a room =
designed for=20
that purpose. My ideal design room is a pleasant room. It =
has plenty=20
of windows and light. The walls are covered literally floor =
to=20
ceiling with white board. (You can buy 4x8 sheets of =
Melamine at a=20
place like Home Depot and screw them onto the wall yourself =
if you=20
like.) This is not a conference room -- toss the conference =
table=20
and hideously uncomfortable chairs (designed, I think, to =
make=20
conferences as short as possible), and replace them with a=20
comfortable couch and a few armchairs. You'll need a =
well-stocked=20
fridge and a few small tables that can be moved where =
they're=20
needed. The main design tool in use will be the white-board =
marker=20
and eraser, but you'll also want an LCD projector hooked up =
to a=20
networked machine to make it easy for the group to work =
together on=20
written documents. Images are transferred from the white =
board to=20
the computer with a high-res digital camera. In the best of =
all=20
worlds, you'd combine the design room with an implementation =
room of=20
the type described by Beck in his XP book -- add a few =
workstation=20
clusters and some private space for people to be alone when =
they=20
need to be.</P>
<P>You won't find a space like this in a typical office, so =
you'll=20
probably have to make one. Get out a screwdriver, rip up the =
cubes,=20
and put one together. If the facilities people don't like =
it, tough.=20
What's more important to the success of the company: =
producing=20
high-quality software or supporting some archaic notion of =
what a=20
"proper" office should look like?</P><A name=3D5>
<P><STRONG class=3Dsubhead>Design and architecture</STRONG> =
<BR>One of=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -