📄 the oo design process1.mht
字号:
the more heinous crimes perpetrated by Microsoft is the =
introduction=20
of the verb "to architect" into English. Architects =
<I>design</I>=20
buildings; they do not "architect" them. The reason I bring =
up this=20
malapropism is that this specific abuse of the language =
artificially=20
implies that a building's architect and a computer program's =
architect are engaged in fundamentally different activities. =
I=20
strongly believe that architecture is architecture, whether =
you're=20
designing a building or whether you're designing software. =
For=20
example, Christopher Alexander -- an architect of buildings =
--=20
conceived the notion of a design pattern (see <I>A Pattern =
Language:=20
Towns, Buildings, Construction</I> in <A=20
=
href=3D"http://www-106.ibm.com/developerworks/library/oo-design1/index.ht=
ml#resources">Resources</A>)=20
and design patterns are fundamental to contemporary software =
architecture.</P>
<P>If you were to walk up to a contractor and say, "I want =
you to=20
build a house for me; how much will it cost, and when will =
you have=20
it finished?" he'd look at you as if you were crazy. =
Programmers=20
definitively answer equally vague questions all the time, =
however,=20
and people wonder why software is rarely delivered on time =
and=20
within budget. Moreover, no contractor would even consider =
starting=20
construction on something as complex as a building without =
some sort=20
of plan. Plans developed by contractors themselves will =
typically=20
not yield as nice a building as those developed by =
architects,=20
however. Contractors will naturally design for ease of =
construction=20
and low cost, which are not necessarily the best choices for =
a=20
building that you plan to live in. Programmers, similarly, =
are=20
typically not the best equipped people for designing =
programs, since=20
they have different priorities than the end user. This is =
not to say=20
that a good architect won't know how to construct what he's=20
designing -- I'm convinced that the best software architects =
are=20
also the best programmers -- but that design and =
construction are=20
different activities and need not be performed by the same=20
people.</P>
<P>The first step in designing a building is meeting with =
the client=20
and figuring out how the building is going to be used. =
Architects=20
are interested in the client's aesthetics, of course, but =
they ask=20
many other questions. What are your hobbies? (Do you need=20
specialized space for them?) Are there pets? (Do you want a=20
cat-feeding station in the kitchen?) Do you have children? =
(Do they=20
need a playroom?) How many? (How big should the playroom =
be?) All of=20
these things influence the design of a building. If an =
activity=20
that's going to be performed in the building is unfamiliar =
to the=20
architect, then he or she will have to learn something about =
that=20
activity to arrive at a satisfactory design. If the client =
is a koi=20
keeper, for example, the architect is going to have to learn =
about=20
pond technology -- not at the level of a koi keeper (a =
"domain=20
expert" in design parlance), but at least at the level of a =
well=20
informed layperson. Note that the emphasis is on how the =
building=20
will be used. Construction considerations, though they're =
always in=20
the back of the architect's mind and do influence the =
design, are=20
not primary.</P>
<P>The next step is to sketch potential buildings, rooms, =
grounds,=20
and so forth. Lots of things change at this point -- rooms =
move=20
around and change shape, fixtures and walls are added and =
removed.=20
Only when the client's needs are correctly reflected by the =
sketches=20
will a set of "final" plans be created, but even these plans =
aren't=20
really final. They're submitted to contractors and =
engineers, all of=20
whom request changes, all of which (if they're visible, at =
least, or=20
affect cost or schedule) are run by the client. Only then =
does=20
construction begin.</P>
<P>The level of detail in the plans is also relevant. Much =
of the=20
design work is done as the building is being constructed. =
The=20
architect shows where the walls go, but the contractor =
figures out=20
the details -- stud placement, framing for the windows and =
doors,=20
and so on. The architect shows where the electrical outlets =
go, but=20
the electrician figures out how to route the wires and where =
the=20
electrical entrance goes. The plans show the drains and =
plumbing=20
fixtures, but the plumber figures out how to route the pipes =
and=20
hook up to the water main and sewer. That's not to say that =
these=20
parts of the building aren't designed, but rather that this =
part of=20
the design is done by the specialist who's doing the =
construction.=20
This design work is often done informally -- on the site as =
work=20
progresses. Moreover, most of the design artifacts, like =
scraps of=20
paper with drawings on them or sketches made on studs inside =
the=20
wall, are discarded because they aren't relevant after the =
object is=20
built. When the specialist needs to do something that =
affects other=20
specialists or the overall design of the building, then the =
ball is=20
passed back to the architect, who modifies the master plans =
(after=20
consulting the client).</P>
<P>Given simple and complex ways to solve the same problem, =
the=20
simple way is always used provided that it doesn't impact =
the=20
integrity or aesthetics of the structure. Nonetheless, =
sometimes the=20
only way to do something is complicated. It's also important =
to note=20
that the level of detail required before construction begins =
is a=20
function of the complexity of the structure. You can design =
a dog=20
house on a napkin. A house requires more detail. In a =
skyscraper,=20
virtually every pipe and electrical conduit is designed =
(though the=20
positions of the walls sometimes aren't!).</P><A name=3D6>
<P><STRONG class=3Dsubhead>Summing up</STRONG> <BR>The =
process I just=20
described is essentially the same process that I use to =
create=20
software, and it's that process that this column will =
demonstrate=20
piece by piece. Starting next month, I'll go into lots of =
detail so=20
that the detail can be put into context. Many of these =
operations=20
actually occur in parallel, and we'll see that in upcoming =
months:=20
<OL>
<LI>Learn about the problem domain.=20
<LI>Interview the users and determine their needs and =
goals.=20
<LI>Develop the problem statement.=20
<LI>Design the user interface.=20
<LI>Develop the use cases.=20
<LI>Rough out a draft static model.=20
<LI>Develop the dynamic model while refining the static =
model.=20
<LI>Implement. </LI></OL>
<P></P>
<P>As I go through these steps, I intend to capture the =
entire=20
process as it occurs, including the mistakes I make and how =
I fix=20
them. By the time we're finished, you'll have a complete =
(and=20
realistic) picture of the design process.</P><A =
name=3Dresources>
<P><STRONG class=3Dsubhead>Resources</STRONG>=20
<UL>
<LI>Check out <I><A=20
=
href=3D"http://www.amazon.com/exec/obidos/ASIN/0201628783/alleiholuasso">=
Succeeding=20
with Objects: Decision Frameworks for Project =
Management</A></I>=20
by Adele Goldberg and Kenneth Rubin, a stunningly good =
book for=20
managers who want to move their shops into an OO =
environment.=20
<LI>RUP (the Rational Unified Process) is described by =
Ivar=20
Jacobson, Grady Booch, and James Rumbaugh in <I><A=20
=
href=3D"http://www.amazon.com/exec/obidos/ASIN/0201571692/alleiholuasso">=
The=20
Unified Software Development Process</A></I>.=20
<LI>XP (Extreme Programming) is described by Kent Beck in =
<I><A=20
=
href=3D"http://www.amazon.com/exec/obidos/ASIN/0201616416/alleiholuasso">=
Extreme=20
Programming Explained: Embrace Change</A></I>. XP is=20
controversial, but I expect that a lot of the controversy =
comes=20
from people making assumptions as to what Beck is talking =
about=20
without having first read his book. XP and RUP actually =
integrate=20
quite nicely, as described by Grady Booch in a draft =
chapter of=20
his new OO-Design book, found at <A=20
=
href=3D"http://www.objectmentor.com/publications/RUPvsXP.pdf">http://www.=
objectmentor.com/publications/RUPvsXP.pdf</A>=20
(PDF). The <A=20
=
href=3D"http://www.objectmentor.com/base.asp?id=3D40">ObjectMentor Web=20
site</A> also has a wealth of useful material on this =
topic.=20
<LI>You can get a copy of my UML templates for Visio from =
the=20
Goodies section of <A href=3D"http://www.holub.com/">my =
Web=20
site</A>.=20
<LI>Read more about design and architecture in <I><A=20
=
href=3D"http://www.amazon.com/exec/obidos/ASIN/0195019199/alleiholuasso">=
A=20
Pattern Language: Towns, Buildings, Construction</A></I> =
by=20
Christopher Alexander, Sara Ishikawa, and Murray=20
Silverstein.</LI></UL><A name=3Dauthor>
<P><STRONG class=3Dsubhead>About the author</STRONG> =
<BR><!-- <img SRC=3D"author.jpg" BORDER=3D0 width=3D64 height=3D71 =
align=3DLEFT> -->Allen=20
Holub has been working in the computer industry since 1979. =
He is=20
widely published in magazines (<I>Dr. Dobb's Journal</I>,=20
<I>Programmers Journal</I>, <I>Byte</I>, <I>MSJ</I>, among =
others)=20
and is a Contributing Editor to the online magazine <A=20
href=3D"http://www.javaworld.com/">JavaWorld</A>. He has =
eight books=20
to his credit, the latest of which (<A=20
=
href=3D"http://www.amazon.com/exec/obidos/ASIN/1893115100/alleiholuasso">=
<I>Taming=20
Java Threads</I></A>) covers the traps and pitfalls of Java=20
threading. He's been designing and building object-oriented =
software=20
for longer than he cares to remember. After eight years as a =
C++=20
programmer, Allen abandoned C++ for Java programming in =
early 1996.=20
He's been teaching programming (first C, then C++ and MFC, =
now=20
OO-Design and Java programming) both on his own and for the=20
University of California Berkeley Extension since 1982. =
Allen offers=20
both public classes and in-house training in Java technology =
and=20
object-oriented design topics. He also does object-oriented =
design=20
consulting and contract Java programming. Visit Allen's Web =
site at=20
<A =
href=3D"http://www.holub.com/">http://www.holub.com/</A>.</P><!-- End =
paper --><BR></TD>
<TD vAlign=3Dtop width=3D8><!-- gutter--><IMG height=3D1=20
src=3D"http://www-106.ibm.com/developerworks/images/c.gif"=20
width=3D8> </TD></TR><!-- gutter -->
<TR height=3D8 vAlign=3Dtop>
<TD vAlign=3Dtop width=3D8><!-- gutter --></TD>
<TD vAlign=3Dtop width=3D8><!-- gutter --></TD>
<TD vAlign=3Dtop width=3D8><!-- gutter --></TD></TR>
<TR height=3D8 vAlign=3Dtop>
<TD vAlign=3Dtop width=3D8><!-- gutter --></TD>
<TD vAlign=3Dtop width=3D8><!-- rate article form -->
<TABLE border=3D0 cellPadding=3D0 cellSpacing=3D0 =
width=3D"100%">
<TBODY>
<TR>
<TD height=3D1 width=3D"100%"><SPACER type=3D"block"=20
height=3D"1"></TD></TR>
<TR>
<TD align=3Dleft bgColor=3D#3333cc height=3D3 =
vAlign=3Dtop=20
width=3D"100%"><IMG border=3D0 height=3D3=20
=
src=3D"http://www-106.ibm.com/developerworks/images/blueline.gif"=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -