⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 the oo design process7.mht

📁 VC书籍介绍C++的应用的TheOODesignProcess.zip 电子书好用的
💻 MHT
📖 第 1 页 / 共 5 页
字号:
              <LI>Gets permission to make deposit from bank officer.=20
              <LI>Updates passbook.</FONT> </LI></UL></TD>
          <TD align=3Dleft vAlign=3Dbaseline><FONT face=3D"HELVETICA, =
HELV, ARIAL"=20
            size=3D-1>Parent (authorizes transactions for), <BR>Kid =
(makes=20
            requests of)</FONT> </TD></TR>
        <TR>
          <TD align=3Dleft vAlign=3Dbaseline><FONT face=3D"HELVETICA, =
HELV, ARIAL"=20
            size=3D-1>Account</FONT> </TD>
          <TD align=3Dleft vAlign=3Dbaseline><FONT face=3D"HELVETICA, =
HELV, ARIAL"=20
            size=3D-1>????</FONT> </TD>
          <TD align=3Dleft vAlign=3Dbaseline><FONT face=3D"HELVETICA, =
HELV, ARIAL"=20
            size=3D-1>????</FONT> </TD></TR>
        <TR>
          <TD align=3Dleft vAlign=3Dbaseline><FONT face=3D"HELVETICA, =
HELV, ARIAL"=20
            size=3D-1>Passbook</FONT> </TD>
          <TD align=3Dleft vAlign=3Dbaseline>
            <UL>
              <LI><FONT face=3D"HELVETICA, HELV, ARIAL" size=3D-1>Tracks =
transaction=20
              history</FONT></LI></UL></TD>
          <TD align=3Dleft vAlign=3Dbaseline><FONT face=3D"HELVETICA, =
HELV, ARIAL"=20
            size=3D-1>Kid (looks at it),<BR>Teller (updates it)</FONT> =
</TD></TR>
        <TR>
          <TD align=3Dleft vAlign=3Dbaseline><FONT face=3D"HELVETICA, =
HELV, ARIAL"=20
            size=3D-1>Deposit slip</FONT> </TD>
          <TD align=3Dleft vAlign=3Dbaseline>
            <UL>
              <LI><FONT face=3D"HELVETICA, HELV, ARIAL" =
size=3D-1>Identifies the=20
              amount of the deposit</FONT></LI></UL></TD>
          <TD align=3Dleft vAlign=3Dbaseline><FONT face=3D"HELVETICA, =
HELV, ARIAL"=20
            size=3D-1>Kid (fills it out),<BR>Parent (authorizes =
it),<BR>Teller=20
            (transfers it to Passbook),<BR>Passbook (records it)</FONT> =
</TD>
          <TD>&nbsp;</TD></TR></TBODY></TABLE>
      <P>Remember, the organization I've presented here is more for the=20
      convenience of the user of the use case than the creator of the =
use case.=20
      </P>
      <P>Surprisingly, I can't think of anything for objects of the =
Account=20
      class to do in this system. The current balance is held by the =
passbook,=20
      which also keeps a record of the transactions on the account. I =
suspect,=20
      then, that the account and the passbook are the same thing; all =
that the=20
      Account does is assign some identifying information to the =
transaction=20
      record. But if the kid/customer is holding their passbook, then =
there's no=20
      need to store the identifying information in the account as well; =
you can=20
      just ask kids for their passbooks to find out what accounts they =
own.</P>
      <P>This issue really highlights the difference between a =
database-style,=20
      entity-relationship (ER) worldview and an object-oriented (OO) =
worldview.=20
      Mapping one worldview to the other is called <I>object-relational=20
      mapping</I>, and that mapping is rarely straightforward, since you =
need to=20
      reconcile two conflicting organizational strategies. It's rare =
that a good=20
      object model will make a good database schema (or vice versa). In =
the=20
      current example, an ER worldview might consider Customers, =
Accounts, and=20
      Passbooks all to be valid entities. The Customer contains=20
      customer-specific identification information and identifies =
various=20
      accounts that the customer owns, the Passbook contains transaction =

      histories, and the Account contains account-specific information =
like=20
      current balance. The object model doesn't work that way for =
reasons I just=20
      discussed. Since there's nothing for an Account to <I>do</I>, it's =
not a=20
      legitimate class.</P>
      <P>In an OO system, a class shouldn't exist unless there's =
something for=20
      it to <I>do</I>; there must be responsibilities (operations). In =
fact, a=20
      class is defined solely by what it can do -- the data that it uses =
to=20
      perform those tasks is an irrelevant implementation detail that =
should be=20
      hidden from the rest of the world. An account might encapsulate =
data, but=20
      I can't think of any operations that it will perform, thus Account =
is not=20
      a proper class. (See <A=20
      =
href=3D"http://www-106.ibm.com/developerworks/components/library/co-desig=
n7.html?dwzone=3Dcomponents#resources">Resources</A>=20
      for more on this way of looking at OO systems.)</P>
      <P>Put another way, object modelers and entity modelers have =
fundamentally=20
      different worldviews. Object modelers are interested almost =
exclusively in=20
      operations -- what the objects do. The state data that an object =
must hold=20
      to implement those operations is usually irrelevant this early in =
the=20
      design process. A static attribute is of interest to an object =
modeler=20
      only if it can be used to distinguish one class of objects from =
another.=20
      (For example, employees have salaries, people don't, so the salary =

      attribute serves as a distinguishing characteristic of Employee.) =
Database=20
      entity modelers, however, concern themselves solely with the =
static=20
      attributes -- the operations are immaterial to them. The net =
result is=20
      that organizations that are anathema to entity modelers (classes =
with no=20
      state data at all, one-to-one and many-to-many relationships =
between=20
      classes, etc.) appear all over the place in OO systems. </P>
      <P>The final culture-clash issue surrounds the organization of the =
static=20
      data. In an OO system, for example, the members of a committee =
would=20
      effectively be contained within the Committee class. That is, the =
members=20
      would be static attributes of the Committee class. In a relational =
system,=20
      it's more likely that a Committee identifier would be an attribute =
of the=20
      member (so that you could join or select on a committee name).</P>
      <P>But I digress. The foregoing notwithstanding, I'll keep =
"Account" in=20
      the list for the time being in case some operation on an account =
surfaces.=20
      I suspect that Account will eventually go away, though.</P>
      <P>So that's about half of the template -- in a way, the least =
significant=20
      half since these parts of the template are more useful in =
organizing my=20
      thoughts than in actually specifying what's going on in the use =
case. Next=20
      time I'll finish up by providing the more significant parts of the =

      use-case definition: the scenarios and the activity diagrams. =
These parts=20
      actually attempt to map out the work flow as the use cases =
progress.</P><!-- Enter list of article resources here --><A=20
      name=3Dresources>
      <P><B class=3Dsubhead>Resources</B>=20
      <UL>
        <LI>This article continues my series on the OO-design process. =
The first=20
        six parts are:=20
        <UL>
          <LI><A=20
          =
href=3D"http://www-106.ibm.com/developerworks/components/library/oo-desig=
n1/index.html">Getting=20
          started</A>=20
          <LI><A=20
          =
href=3D"http://www-106.ibm.com/developerworks/components/library/oo-desig=
n2/index.html">Beginning=20
          to design software</A>=20
          <LI><A=20
          =
href=3D"http://www-106.ibm.com/developerworks/components/library/oo-desig=
n3.html">Refining=20
          the problem definition</A>=20
          <LI><A=20
          =
href=3D"http://www-106.ibm.com/developerworks/components/library/co-desig=
n4.html">Verifying=20
          the analysis</A>=20
          <LI><A=20
          =
href=3D"http://www-106.ibm.com/developerworks/components/library/co-desig=
n5.html">Use=20
          cases, an Introduction</A>=20
          <LI><A=20
          =
href=3D"http://www-106.ibm.com/developerworks/components/library/co-desig=
n6.html">Use=20
          case planning</A> </LI></UL><BR>
        <LI>Workflow diagrams (along with the rest of UML) are described =
nicely=20
        in Martin Fowler and Kendall Scott's <A=20
        =
href=3D"http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=3D0201=
65783X&amp;from=3DNCN454"><I>UML=20
        Distilled</I></A>, 2nd Ed</A>. </LI></UL><!-- Enter author bios =
here; make author heading singular or plural as needed --><A=20
      name=3Dauthor1>
      <P><B class=3Dsubhead>About the author</B> <BR>Allen Holub is the =
CTO at=20
      NetReliance, a San-Francisco-based company that's building a =
secure global=20
      infrastructure for conducting trusted business transactions over =
the net.=20
      (Yes, we're hiring.) He has worked in the computer industry since =
1979,=20
      and is widely published. Allen has <A=20
      href=3D"http://www.holub.com/allenholub.html#books">eight =
books</A> to his=20
      credit, the latest of which covers the traps and pitfalls of Java=20
      threading (<A=20
      =
href=3D"http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=3D1893=
115100&amp;from=3DNCN454"=20
      target=3D_blank>Taming Java Threads</A> [Berkeley: Apress, 2000; =
ISBN=20
      1893115100]).</P>
      <P>He's been designing and building OO software for longer than he =
cares=20
      to remember (in C++ and Java). He teaches OO-Design and Java for =
the=20
      University of California, Berkeley, Extension (since 1982). =
Contact Allen=20
      at <A href=3D"mailto:allen@holub.com">allen@holub.com</A> or at <A =

      =
href=3D"mailto:allen.holub@net-reliance.com">allen.holub@net-reliance.com=
</A>.</P>
      <P>Allen is also a composer, artist, and instrument-rated =
commercial=20
      pilot. He holds B.A. degrees from the University of California, =
Berkeley,=20
      in Medieval History and Computer Science.</P><BR clear=3Dall><IMG =
alt=3D""=20
      border=3D0 height=3D5 src=3D"http://www.ibm.com/i/c.gif" =
width=3D100><BR><!-- END PAPER BODY --><BR clear=3Dall><IMG alt=3D"" =
border=3D0=20
      height=3D10 src=3D"http://www.ibm.com/i/c.gif" =
width=3D100><BR><!-- REPEAT ICON LINKS AT BOTTOM OF PAGE -->
      <TABLE border=3D0 cellPadding=3D0 cellSpacing=3D0 width=3D"100%">
        <TBODY>
        <TR vAlign=3Dtop><!-- Icon Links : Comment out Discuss, Zip, and =
PDF as appropriate; enter file sizes  -->
          <TD align=3Dright width=3D"100%"><NOBR><!--
<a href=3D""><img src=3D"/developerworks/i/icon-discuss.gif" =
width=3D"42" height=3D"26" border=3D"0" alt=3D""></a>

<a =
href=3D"ftp://www6.software.ibm.com/software/developer/library/xxx.zip"><=
img src=3D"/developerworks/i/icon-zip.gif" width=3D"30" height=3D"26" =
border=3D"0" alt=3D"zip file - xxxXB"></a>
--><A=20
            =
href=3D"ftp://www6.software.ibm.com/software/developer/library/co-design7=
.pdf"><IMG=20
            alt=3D"PDF - 70KB" border=3D0 height=3D26=20
            src=3D"http://www-106.ibm.com/developerworks/i/icon-pdf.gif" =

            width=3D35></A> <A =
href=3D"javascript:void%20newWindow()"><IMG alt=3D""=20
            border=3D0 height=3D26=20
            =
src=3D"http://www-106.ibm.com/developerworks/i/icon-email.gif"=20
            width=3D46></A></NOBR></TD>
          <TD width=3D5><IMG alt=3D"" border=3D0 height=3D1=20
            src=3D"http://www.ibm.com/i/c.gif" width=3D5></TD></TR><!-- =
Black Line Separator -->
        <TR vAlign=3Dtop>
          <TD bgColor=3D#000000 colSpan=3D2><IMG border=3D0 height=3D1=20
            src=3D"http://www.ibm.com/i/c.gif" width=3D100></TD></TR>
        <TR vAlign=3Dtop>
          <TD bgColor=3D#ffffff colSpan=3D2><IMG border=3D0 height=3D8=20
            src=3D"http://www.ibm.com/i/c.gif" =
width=3D100></TD></TR></TBODY></TABLE><!-- RATE ARTICLE FORM -->
      <TABLE border=3D0 cellPadding=3D0 cellSpacing=3D0 width=3D"100%">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -