﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-semovy-文章分类-设计模式</title><link>http://www.blogjava.net/WshmAndLily/category/10982.html</link><description /><language>zh-cn</language><lastBuildDate>Thu, 24 Apr 2008 15:48:28 GMT</lastBuildDate><pubDate>Thu, 24 Apr 2008 15:48:28 GMT</pubDate><ttl>60</ttl><item><title>UML 类图关系</title><link>http://www.blogjava.net/WshmAndLily/articles/194831.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Tue, 22 Apr 2008 09:35:00 GMT</pubDate><guid>http://www.blogjava.net/WshmAndLily/articles/194831.html</guid><wfw:comment>http://www.blogjava.net/WshmAndLily/comments/194831.html</wfw:comment><comments>http://www.blogjava.net/WshmAndLily/articles/194831.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/WshmAndLily/comments/commentRss/194831.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/WshmAndLily/services/trackbacks/194831.html</trackback:ping><description><![CDATA[<table cellspacing="0" cellpadding="0" width="760" align="center" border="0">
    <tbody>
        <tr>
            <td>
            <div class="title" align="center">UML类图关系全面剖析<br />
            </div>
            </td>
        </tr>
        <tr>
            <td height="20">&nbsp;</td>
        </tr>
        <tr>
            <td>
            <div class="formtitle" align="center">2008-04-10 作者:一雨田的专栏 来源:CSDN<br />
            </div>
            </td>
        </tr>
        <tr>
            <td height="16">&nbsp;</td>
        </tr>
        <tr>
            <td valign="top">
            <table cellspacing="0" cellpadding="0" width="86%" align="center" border="0">
                <tbody>
                    <tr>
                        <td class="content" valign="top">
                        <p>UML的类图关系分为： 关联、聚合/组合、依赖、泛化（继承）。而其中关联又分为双向关联、单向关联、自身关联；下面就让我们一起来看看这些关系究竟是什么，以及它们的区别在哪里。</p>
                        <p><strong>1、关联</strong></p>
                        <p><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_1.JPG" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}"></span></p>
                        <p><span class="content"><font style="line-height: 120%">双向关联：</font></span></p>
                        <p><span class="content"><font style="line-height: 120%">C1-C2：指双方都知道对方的存在，都可以调用对方的公共属性和方法。</font></span></p>
                        <p><span class="content"><font style="line-height: 120%">在GOF的设计模式书上是这样描述的：虽然在分析阶段这种关系是适用的，但我们觉得它对于描述设计模式内的类关系来说显得太抽象了，因为在设计阶段关联关系必须被映射为对象引用或指针。对象引用本身就是有向的，更适合表达我们所讨论的那种关系。所以这种关系在设计的时候比较少用到，关联一般都是有向的。</font></span></p>
                        <p><span class="content"><font style="line-height: 120%">使用ROSE 生成的代码是这样的：</font> </span></p>
                        <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 414px; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid; height: 218px">
                        <div><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C1&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>public:<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>&nbsp;&nbsp;&nbsp;&nbsp;C2*&nbsp;theC2;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C2&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>public:<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>&nbsp;&nbsp;&nbsp;&nbsp;C1*&nbsp;theC1;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};</span></div>
                        </div>
                        <p class="content"><font style="line-height: 120%">双向关联在代码的表现为双方都拥有对方的一个指针，当然也可以是引用或者是值。</font></p>
                        <p class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_17.JPG" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}"></p>
                        <p class="content"><font style="line-height: 120%">单向关联:</font></p>
                        <p class="content"><font style="line-height: 120%">C3-&gt;C4：表示相识关系，指C3知道C4，C3可以调用C4的公共属性和方法。没有生命期的依赖。一般是表示为一种引用。</font></p>
                        <p class="content"><font style="line-height: 120%">生成代码如下：</font></p>
                        <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 414px; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid; height: 186px">
                        <div><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C3&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>public:<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>&nbsp;&nbsp;&nbsp;&nbsp;C4*&nbsp;theC4;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C4&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};</span></div>
                        </div>
                        <p class="content"><font style="line-height: 120%">单向关联的代码就表现为C3有C4的指针，而C4对C3一无所知。</font></p>
                        <p><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_31.JPG" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}"></span></p>
                        <p><span class="content"><font style="line-height: 120%">自身关联（反身关联）：</font></span></p>
                        <p><span class="content"><font style="line-height: 120%">自己引用自己，带着一个自己的引用。</font></span></p>
                        <p><span class="content"><font style="line-height: 120%">代码如下：</font></span></p>
                        <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 415px; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid; height: 106px">
                        <div><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C14&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>public:<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>&nbsp;&nbsp;&nbsp;&nbsp;C14*&nbsp;theC14;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};</span></div>
                        </div>
                        <p class="content"><font style="line-height: 120%">就是在自己的内部有着一个自身的引用。</font></p>
                        <p class="content"><strong>2、聚合/组合</strong></p>
                        <p class="content">当类之间有整体-部分关系的时候，我们就可以使用组合或者聚合。</p>
                        <p class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_39.JPG" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}"></p>
                        <p class="content"><font style="line-height: 120%">聚合：表示C9聚合C10，但是C10可以离开C9而独立存在（独立存在的意思是在某个应用的问题域中这个类的存在有意义。这句话怎么解，请看下面组合里的解释）。</font></p>
                        <p class="content"><font style="line-height: 120%">代码如下：</font></p>
                        <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 413px; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid; height: 202px">
                        <div><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C9&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>public:<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>&nbsp;&nbsp;&nbsp;&nbsp;C10&nbsp;theC10;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C10&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top></span></div>
                        </div>
                        <p><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_54.JPG" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}"></span></p>
                        <p class="content"><span class="content"><font style="line-height: 120%">组合（也有人称为包容）：一般是实心菱形加实线箭头表示，如上图所示，表示的是C8被C7包容，而且C8不能离开C7而独立存在。但这是视问题域而定的，例如在关心汽车的领域里，轮胎是一定要组合在汽车类中的，因为它离开了汽车就没有意义了。但是在卖轮胎的店铺业务里，就算轮胎离开了汽车，它也是有意义的，这就可以用聚合了。在《敏捷开发》中还说到，A组合B，则A需要知道B的生存周期，即可能A负责生成或者释放B，或者A通过某种途径知道B的生成和释放。</font></span></p>
                        <p class="content"><span class="content"><font style="line-height: 120%">他们的代码如下：</font></span></p>
                        <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 412px; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid; height: 170px">
                        <div><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C7&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>public:<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>&nbsp;&nbsp;&nbsp;&nbsp;C8&nbsp;theC8;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C8&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};</span></div>
                        </div>
                        <p class="content">可以看到，代码和聚合是一样的。具体如何区别，可能就只能用语义来区分了。</p>
                        <p class="content"><font style="line-height: 120%"><strong>3、依赖</strong></font></p>
                        <p class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_67.JPG" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}"></p>
                        <p class="content"><font style="line-height: 120%">依赖:</font></p>
                        <p class="content"><font style="line-height: 120%">指C5可能要用到C6的一些方法，也可以这样说，要完成C5里的所有功能，一定要有C6的方法协助才行。C5依赖于C6的定义，一般是在C5类的头文件中包含了C6的头文件。ROSE对依赖关系不产生属性。</font></p>
                        <p class="content"><font style="line-height: 120%">注意，要避免双向依赖。一般来说，不应该存在双向依赖。</font></p>
                        <p class="content"><font style="line-height: 120%">ROSE生成的代码如下：</font></p>
                        <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 412px; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid; height: 266px">
                        <div><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>//&nbsp;C5.h<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>＃i nclude&nbsp;"C6.h"<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C5&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>//&nbsp;C6.h<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>＃i nclude&nbsp;"C5.h"<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C6<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top></span></div>
                        </div>
                        <p class="content"><font style="line-height: 120%">虽然ROSE不生成属性，但在形式上一般是A中的某个方法把B的对象作为参数使用(假设A依赖于B)。如下：</font></p>
                        <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 414px; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid; height: 90px">
                        <div><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>＃i nclude&nbsp;"B.h"<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;A<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_5.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;Func(B&nbsp;&amp;b);<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>}</span></div>
                        </div>
                        <p class="content"><font style="line-height: 120%"><strong><font style="line-height: 120%" color="#ff0000">那依赖和聚合\组合、关联等有什么不同呢？</font></strong></font></p>
                        <p class="content"><font style="line-height: 120%">关联是类之间的一种关系，例如老师教学生，老公和老婆，水壶装水等就是一种关系。这种关系是非常明显的，在问题领域中通过分析直接就能得出。</font></p>
                        <p class="content"><font style="line-height: 120%">依赖是一种弱关联，只要一个类用到另一个类，但是和另一个类的关系不是太明显的时候（可以说是&#8220;uses&#8221;了那个类），就可以把这种关系看成是依赖，依赖也可说是一种偶然的关系，而不是必然的关系，就是&#8220;我在某个方法中偶然用到了它，但在现实中我和它并没多大关系&#8221;。例如我和锤子，我和锤子本来是没关系的，但在有一次要钉钉子的时候，我用到了它，这就是一种依赖，依赖锤子完成钉钉子这件事情。</font></p>
                        <p class="content"><font style="line-height: 120%">组合是一种整体-部分的关系，在问题域中这种关系很明显，直接分析就可以得出的。例如轮胎是车的一部分，树叶是树的一部分，手脚是身体的一部分这种的关系，非常明显的整体-部分关系。</font></p>
                        <p class="content"><font style="line-height: 120%">上述的几种关系（关联、聚合/组合、依赖）在代码中可能以指针、引用、值等的方式在另一个类中出现，不拘于形式，但在逻辑上他们就有以上的区别。</font></p>
                        <p class="content"><font style="line-height: 120%">这里还要说明一下，所谓的这些关系只是在某个问题域才有效，离开了这个问题域，可能这些关系就不成立了，例如可能在某个问题域中，我是一个木匠，需要拿着锤子去干活，可能整个问题的描述就是我拿着锤子怎么钉桌子，钉椅子，钉柜子；既然整个问题就是描述这个，我和锤子就不仅是偶然的依赖关系了，我和锤子的关系变得非常的紧密，可能就上升为组合关系（让我突然想起武侠小说的剑不离身，剑亡人亡...）。这个例子可能有点荒谬，但也是为了说明一个道理，就是关系和类一样，它们都是在一个问题领域中才成立的，离开了这个问题域，他们可能就不复存在了。</font></p>
                        <p class="content"><font style="line-height: 120%"><strong>4、泛化（继承）</strong></font></p>
                        <p class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_92.jpg" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}"></p>
                        <p class="content"><font style="line-height: 120%">泛化关系：如果两个类存在泛化的关系时就使用，例如父和子，动物和老虎，植物和花等。</font></p>
                        <p class="content"><font style="line-height: 120%">ROSE生成的代码很简单，如下：</font></p>
                        <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 388px; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid; height: 90px">
                        <div><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>＃i nclude&nbsp;"C11.h"<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C12&nbsp;:&nbsp;public&nbsp;C11<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};</span></div>
                        </div>
                        <p class="content"><strong><font style="line-height: 120%">5、这里顺便提一下模板</font></strong></p>
                        <p class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_99.jpg" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}"></p>
                        <p class="content"><font style="line-height: 120%">上面的图对应的代码如下：</font></p>
                        <div style="border-right: windowtext 0.5pt solid; padding-right: 5.4pt; border-top: windowtext 0.5pt solid; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; border-left: windowtext 0.5pt solid; width: 384px; word-break: break-all; padding-top: 4px; border-bottom: windowtext 0.5pt solid; height: 90px">
                        <div><span class="content"><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>template&lt;int&gt;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>class&nbsp;C13&nbsp;<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_3.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top><img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_4.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>...{<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_8.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top>};<br />
                        <img style="cursor: pointer" onclick="javascript:window.open(this.src);" src="http://www.uml.org.cn/oobject/images/346970_2.gif" onload="javascript:if(this.width  alt="" />1000){this.resized=true;this.style.width=1000;}" align=top></span></div>
                        </div>
                        <p class="content"><font style="line-height: 120%">这里再说一下重复度，其实看完了上面的描述之后，我们应该清楚了各个关系间的关系以及具体对应到代码是怎么样的，所谓的重复度，也只不过是上面的扩展，例如A和B有着&#8220;1对多&#8221;的重复度，那在A中就有一个列表，保存着B对象的N个引用，就是这样而已。</font><br />
                        </p>
                        </td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.blogjava.net/WshmAndLily/aggbug/194831.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/WshmAndLily/" target="_blank">semovy</a> 2008-04-22 17:35 <a href="http://www.blogjava.net/WshmAndLily/articles/194831.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>利用java的动态代理写日志</title><link>http://www.blogjava.net/WshmAndLily/articles/179319.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Mon, 04 Feb 2008 19:12:00 GMT</pubDate><guid>http://www.blogjava.net/WshmAndLily/articles/179319.html</guid><wfw:comment>http://www.blogjava.net/WshmAndLily/comments/179319.html</wfw:comment><comments>http://www.blogjava.net/WshmAndLily/articles/179319.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/WshmAndLily/comments/commentRss/179319.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/WshmAndLily/services/trackbacks/179319.html</trackback:ping><description><![CDATA[1.测试的实体Bean&nbsp; Person类<br />
<br />
Person.java<br />
<br />
<p>package com.semovy.bean;</p>
<p>public class Person {<br />
&nbsp;<br />
&nbsp;private String id;</p>
<p>&nbsp;private String name;</p>
<p>&nbsp;private String note;</p>
<p>&nbsp;public String getId() {<br />
&nbsp;&nbsp;return id;<br />
&nbsp;}</p>
<p>&nbsp;public void setId(String id) {<br />
&nbsp;&nbsp;this.id = id;<br />
&nbsp;}</p>
<p>&nbsp;public String getName() {<br />
&nbsp;&nbsp;return name;<br />
&nbsp;}</p>
<p>&nbsp;public void setName(String name) {<br />
&nbsp;&nbsp;this.name = name;<br />
&nbsp;}</p>
<p>&nbsp;public String getNote() {<br />
&nbsp;&nbsp;return note;<br />
&nbsp;}</p>
<p>&nbsp;public void setNote(String note) {<br />
&nbsp;&nbsp;this.note = note;<br />
&nbsp;}</p>
<p>&nbsp;public Person(String id, String name, String note) {<br />
&nbsp;&nbsp;super();<br />
&nbsp;&nbsp;this.id = id;<br />
&nbsp;&nbsp;this.name = name;<br />
&nbsp;&nbsp;this.note = note;<br />
&nbsp;}</p>
<p>&nbsp;@Override<br />
&nbsp;public String toString() {<br />
&nbsp;&nbsp;// TODO Auto-generated method stub<br />
&nbsp;&nbsp;return "id: " + id + " name: " +&nbsp; name + " note: " + note;<br />
&nbsp;}</p>
<p>}<br />
2.操作Person实体类的接口PersonService<br />
<br />
PersonService.java<br />
<br />
</p>
<p>package com.semovy.service;</p>
<p>import java.util.ArrayList;<br />
import java.util.List;</p>
<p>import com.semovy.bean.Person;</p>
<p>public interface PersonService {</p>
<p>&nbsp;public List&lt;Person&gt; persons = new ArrayList&lt;Person&gt;();</p>
<p>&nbsp;public abstract void addPerson(Person person);</p>
<p>&nbsp;public abstract Person getPersonById(String id);</p>
<p>&nbsp;public abstract void deletePersonById(String id);</p>
<p>&nbsp;//public abstract void updatePerson(Person person);</p>
<p>&nbsp;public abstract void displayPersonById(String id);</p>
<p>&nbsp;public abstract void displayAllPersons();<br />
}<br />
3.实现PersonService接口的PersonServiceImpl<br />
<br />
PersonServiceImpl.java<br />
<br />
</p>
<p>package com.semovy.service.impl;</p>
<p>import java.util.Iterator;</p>
<p>import com.semovy.bean.Person;<br />
import com.semovy.service.PersonService;</p>
<p>public class PersonServiceImpl implements PersonService {</p>
<p>&nbsp;public void addPerson(Person person) {<br />
&nbsp;&nbsp;persons.add(person);<br />
&nbsp;}</p>
<p>&nbsp;public void deletePersonById(String id) {<br />
&nbsp;&nbsp;Iterator it = persons.iterator();<br />
&nbsp;&nbsp;while(it.hasNext())<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;Person person = (Person)it.next();<br />
&nbsp;&nbsp;&nbsp;if(person.getId().equals(id))<br />
&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;it.remove();<br />
&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;}</p>
<p>&nbsp;public void displayAllPersons() {<br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;Iterator it = persons.iterator();<br />
&nbsp;&nbsp;while(it.hasNext())<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;Person person = (Person)it.next();<br />
&nbsp;&nbsp;&nbsp;System.out.println(person.toString());<br />
&nbsp;&nbsp;}<br />
&nbsp;}</p>
<p>&nbsp;public void displayPersonById(String id) {<br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;Iterator it = persons.iterator();<br />
&nbsp;&nbsp;while(it.hasNext())<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;Person person = (Person)it.next();<br />
&nbsp;&nbsp;&nbsp;if(person.getId().equals(id))<br />
&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(person.toString());<br />
&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;<br />
&nbsp;}</p>
<p>&nbsp;public Person getPersonById(String id) {<br />
&nbsp;&nbsp;Iterator it = persons.iterator();<br />
&nbsp;&nbsp;while(it.hasNext())<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;Person person = (Person)it.next();<br />
&nbsp;&nbsp;&nbsp;if(person.getId().equals(id))<br />
&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;return person;<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;return null;<br />
&nbsp;}</p>
<p>&nbsp;/*public void updatePerson(Strin) {<br />
&nbsp;&nbsp;Iterator it = persons.iterator();<br />
&nbsp;&nbsp;while(it.hasNext())<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;Person person = (Person)it.next();<br />
&nbsp;&nbsp;&nbsp;if(person == aperson)<br />
&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;persons.set(arg0, arg1)<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;}*/</p>
<p>}<br />
</p>
<p>4.写日志的代理类LogProxy&nbsp;&nbsp; 它实现了InvocationHandler接口<br />
<br />
LogProxy.java<br />
<br />
</p>
<p>package com.semovy.bean;</p>
<p>import java.lang.reflect.InvocationHandler;<br />
import java.lang.reflect.Method;<br />
import java.lang.reflect.Proxy;</p>
<p>import org.apache.log4j.Level;<br />
import org.apache.log4j.Logger;</p>
<p><br />
public class LogProxy implements InvocationHandler {<br />
&nbsp;<br />
&nbsp;Logger logger = Logger.getLogger(this.getClass().getName());<br />
&nbsp;private Object delegate = null;<br />
&nbsp;<br />
&nbsp;public Object getDelegate() {<br />
&nbsp;&nbsp;return delegate;<br />
&nbsp;}</p>
<p>&nbsp;public void setDelegate(Object delegate) {<br />
&nbsp;&nbsp;this.delegate = delegate;<br />
&nbsp;}</p>
<p>&nbsp;public Object bind(Object delegate) {<br />
&nbsp;&nbsp;this.delegate = delegate;<br />
&nbsp;&nbsp;return Proxy.newProxyInstance(delegate.getClass().getClassLoader(),<br />
&nbsp;&nbsp;&nbsp;&nbsp;delegate.getClass().getInterfaces(),this);<br />
&nbsp;}</p>
<p>&nbsp;public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {<br />
&nbsp;&nbsp;Object result = null;<br />
&nbsp;&nbsp;try<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;logger.log(Level.INFO,method.getName() +&nbsp; " 开始处理...");<br />
&nbsp;&nbsp;&nbsp;result = method.invoke(this.delegate, args);<br />
&nbsp;&nbsp;&nbsp;logger.log(Level.INFO,method.getName() +&nbsp; " 结束处理...");<br />
&nbsp;&nbsp;}catch(Exception e)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;logger.log(Level.ERROR,e.getLocalizedMessage());<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;return result;<br />
&nbsp;}<br />
}<br />
</p>
<p>5.在eclipse中添加log4j.properties<br />
<br />
log4j.properties<br />
<br />
log4j.rootLogger=DEBUG,stdout<br />
log4j.appender.stdout=org.apache.log4j.ConsoleAppender<br />
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout<br />
log4j.appender.stdout.layout.ConversionPattern=%d %5p (%F:%L) - %m%n<br />
<br />
5.写测试类Test.java<br />
<br />
Test.java<br />
<br />
</p>
<p>package com.semovy.test;</p>
<p>import java.io.File;<br />
import java.io.IOException;<br />
import java.io.PrintWriter;<br />
import java.util.Iterator;<br />
import java.util.List;</p>
<p>import com.semovy.bean.LogProxy;<br />
import com.semovy.bean.Person;<br />
import com.semovy.service.PersonService;<br />
import com.semovy.service.impl.PersonServiceImpl;</p>
<p>public class Test {</p>
<p>&nbsp;/**<br />
&nbsp; * @param args<br />
&nbsp; */<br />
&nbsp;public static void main(String[] args) {</p>
<p>&nbsp;&nbsp;LogProxy logProxy = new LogProxy();<br />
&nbsp;&nbsp;PersonService personService = (PersonService)logProxy.bind(new PersonServiceImpl());<br />
&nbsp;&nbsp;personService.addPerson(new Person("1","name1","note1"));<br />
&nbsp;&nbsp;personService.addPerson(new Person("2","name2","note2"));<br />
&nbsp;&nbsp;personService.addPerson(new Person("3","name3","note3"));<br />
&nbsp;&nbsp;personService.addPerson(new Person("4","name4","note4"));<br />
&nbsp;&nbsp;personService.displayPersonById("3");<br />
&nbsp;&nbsp;personService.displayAllPersons();<br />
&nbsp;&nbsp;Person person = personService.getPersonById("2");<br />
&nbsp;&nbsp;person.setName("名称2");<br />
&nbsp;&nbsp;person.setNote("注脚2");<br />
&nbsp;&nbsp;personService.displayAllPersons();<br />
&nbsp;&nbsp;personService.deletePersonById("2");<br />
&nbsp;&nbsp;personService.displayAllPersons();<br />
&nbsp;&nbsp;//saveToFile(persons,"c:/persons.txt");<br />
&nbsp;}<br />
&nbsp;<br />
&nbsp;public static void saveToFile(List list,String path)<br />
&nbsp;{<br />
&nbsp;&nbsp;System.out.println("开始写入文件...");<br />
&nbsp;&nbsp;try<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;PrintWriter out = new PrintWriter(new File(path));<br />
&nbsp;&nbsp;&nbsp;Iterator it = list.iterator();<br />
&nbsp;&nbsp;&nbsp;while(it.hasNext())<br />
&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;Person person = (Person)it.next();<br />
&nbsp;&nbsp;&nbsp;&nbsp;out.println(person.toString());<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;out.flush();<br />
&nbsp;&nbsp;&nbsp;out.close();<br />
&nbsp;&nbsp;&nbsp;System.out.println("结束写入文件...");<br />
&nbsp;&nbsp;}catch(IOException e)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;System.out.println(e.getLocalizedMessage());<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;<br />
&nbsp;}<br />
}<br />
</p>
<p><br />
6.运行测试结果:<br />
<br />
2008-02-05 02:55:28,926&nbsp; INFO (LogProxy.java:34) - addPerson 开始处理...<br />
2008-02-05 02:55:28,926&nbsp; INFO (LogProxy.java:36) - addPerson 结束处理...<br />
2008-02-05 02:55:28,926&nbsp; INFO (LogProxy.java:34) - addPerson 开始处理...<br />
2008-02-05 02:55:28,926&nbsp; INFO (LogProxy.java:36) - addPerson 结束处理...<br />
2008-02-05 02:55:28,926&nbsp; INFO (LogProxy.java:34) - addPerson 开始处理...<br />
2008-02-05 02:55:28,936&nbsp; INFO (LogProxy.java:36) - addPerson 结束处理...<br />
2008-02-05 02:55:28,936&nbsp; INFO (LogProxy.java:34) - addPerson 开始处理...<br />
2008-02-05 02:55:29,036&nbsp; INFO (LogProxy.java:36) - addPerson 结束处理...<br />
2008-02-05 02:55:29,036&nbsp; INFO (LogProxy.java:34) - displayPersonById 开始处理...<br />
id: 3 name: name3 note: note3<br />
2008-02-05 02:55:29,036&nbsp; INFO (LogProxy.java:36) - displayPersonById 结束处理...<br />
2008-02-05 02:55:29,036&nbsp; INFO (LogProxy.java:34) - displayAllPersons 开始处理...<br />
id: 1 name: name1 note: note1<br />
id: 2 name: name2 note: note2<br />
id: 3 name: name3 note: note3<br />
id: 4 name: name4 note: note4<br />
2008-02-05 02:55:29,046&nbsp; INFO (LogProxy.java:36) - displayAllPersons 结束处理...<br />
2008-02-05 02:55:29,046&nbsp; INFO (LogProxy.java:34) - getPersonById 开始处理...<br />
2008-02-05 02:55:29,046&nbsp; INFO (LogProxy.java:36) - getPersonById 结束处理...<br />
2008-02-05 02:55:29,046&nbsp; INFO (LogProxy.java:34) - displayAllPersons 开始处理...<br />
id: 1 name: name1 note: note1<br />
id: 2 name: 名称2 note: 注脚2<br />
id: 3 name: name3 note: note3<br />
id: 4 name: name4 note: note4<br />
2008-02-05 02:55:29,046&nbsp; INFO (LogProxy.java:36) - displayAllPersons 结束处理...<br />
2008-02-05 02:55:29,046&nbsp; INFO (LogProxy.java:34) - deletePersonById 开始处理...<br />
2008-02-05 02:55:29,046&nbsp; INFO (LogProxy.java:36) - deletePersonById 结束处理...<br />
2008-02-05 02:55:29,046&nbsp; INFO (LogProxy.java:34) - displayAllPersons 开始处理...<br />
id: 1 name: name1 note: note1<br />
id: 3 name: name3 note: note3<br />
id: 4 name: name4 note: note4<br />
2008-02-05 02:55:29,046&nbsp; INFO (LogProxy.java:36) - displayAllPersons 结束处理...<br />
<br />
<br />
</p>
<img src ="http://www.blogjava.net/WshmAndLily/aggbug/179319.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/WshmAndLily/" target="_blank">semovy</a> 2008-02-05 03:12 <a href="http://www.blogjava.net/WshmAndLily/articles/179319.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于项目框架设计的一点学习 </title><link>http://www.blogjava.net/WshmAndLily/articles/145588.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Sun, 16 Sep 2007 13:10:00 GMT</pubDate><guid>http://www.blogjava.net/WshmAndLily/articles/145588.html</guid><wfw:comment>http://www.blogjava.net/WshmAndLily/comments/145588.html</wfw:comment><comments>http://www.blogjava.net/WshmAndLily/articles/145588.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/WshmAndLily/comments/commentRss/145588.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/WshmAndLily/services/trackbacks/145588.html</trackback:ping><description><![CDATA[<p style="background: white; margin: 0cm 0cm 0pt; text-align: center" align="center"><strong><span style="color: purple; font-family: 宋体">关于项目框架设计的一点学习</span> </strong></p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">这两天又在接触一个新项目，对于如何设计一个项目的框架有了点概念，关于web项目（对于oa系统来说）的主体感觉比较需要设计的几部分为：</span> </p>
<p style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; tab-stops: list 18.0pt"><span style="font-family: 宋体">1．&nbsp;</span><span style="font-family: 宋体">页面模板定义：关于view层展示，无论对于top（顶层菜单）+left（左边树状菜单）+right（主体内容）结构还是left+right结构，都需要首先定制一些模板，如struts中可使用tiles定义。</span> </p>
<p style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; tab-stops: list 18.0pt"><span style="font-family: 宋体">2．&nbsp;</span><span style="font-family: 宋体">分页标签：自定义一个比较通用的分页标签或者使用一些框架中自带的（如struts-menu或者JSF中的t:dataScroller），不过比较好的做法是基于其源码编写自己的分页标签。</span> </p>
<p style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; tab-stops: list 18.0pt"><span style="font-family: 宋体">3．&nbsp;</span><span style="font-family: 宋体">DB</span> <span style="font-family: 宋体">设计：可使用Power Deisign等设计数据库表结构，产生相关的表。</span> </p>
<p style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; tab-stops: list 18.0pt"><span style="font-family: 宋体">4．&nbsp;</span><span style="font-family: 宋体">代码自动生成：编写代码生成脚本如build.xml文件的编写（根据DB生成代码，也可以忽略3，先建model，再从model生成代码和数据库schema），生成Struts、Spring、Hibernate相关文件。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">关于代码的整体架构如下：</span> <br />
<img alt="" src="http://www.blogjava.net/images/blogjava_net/wshmandlily/11.JPG" border="0" /><br />
</p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">action</span> <span style="font-family: 宋体">层：处理从view层传递过来的数据。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">service</span> <span style="font-family: 宋体">层：封装业务逻辑，一般同时在spring中声明事务代理。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">dao</span> <span style="font-family: 宋体">层：进行事务中的原子操作，同时在spring中注入相应的sessionFactory。</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="font-family: 宋体">Spring + Struts</span> <span style="font-family: 宋体">取得spring的bean的两种常用方法：</span> </p>
<p style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; text-align: left; tab-stops: list 18.0pt" align="left"><span style="font-family: 宋体">1.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体">DelegatingActionProxy</span> <span style="font-family: 宋体">：将所有action标签中type属性设为org.springframework.web.struts.DelegatingActionProxy　也就是将action委托给了spring，同时在</span> <span style="color: #2a00ff; font-family: 宋体">action-servlets.xml</span> <span style="font-family: 宋体">中配置一个于action标签path属性对应的bean(也就是bean的name值等于action的path值)，如：</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="font-family: 宋体">struts-config.xml</span> <span style="font-family: 宋体">中，以struts的plugin的方式,让spring接管struts的action：</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: teal; font-family: 宋体">&lt;</span> <span style="color: #3f7f7f; font-family: 宋体">action </span><span style="color: #7f007f; font-family: 宋体">name</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"portalForm" </span><span style="color: #7f007f; font-family: 宋体">parameter</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"method" </span><span style="color: #7f007f; font-family: 宋体">path</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"/portalAction" </span><span style="color: #7f007f; font-family: 宋体">type</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"org.springframework.web.struts.DelegatingActionProxy" </span><span style="color: #7f007f; font-family: 宋体">scope</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"request"</span> <span style="color: teal; font-family: 宋体">&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: black; font-family: 宋体">&nbsp;&nbsp;&nbsp; </span><span style="color: teal; font-family: 宋体">&lt;</span> <span style="color: #3f7f7f; font-family: 宋体">forward </span><span style="color: #7f007f; font-family: 宋体">name</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"portalEdit" </span><span style="color: #7f007f; font-family: 宋体">path</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"</span> <span style="color: #2a00ff; font-family: 宋体">pages/portalEdit.jsp" </span><span style="color: teal; font-family: 宋体">/&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: black; font-family: 宋体">&nbsp;&nbsp;&nbsp; </span><span style="color: teal; font-family: 宋体">&lt;</span> <span style="color: #3f7f7f; font-family: 宋体">forward </span><span style="color: #7f007f; font-family: 宋体">name</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"portalList" </span><span style="color: #7f007f; font-family: 宋体">path</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"</span> <span style="color: #2a00ff; font-family: 宋体">pages/portalList.jsp " </span><span style="color: teal; font-family: 宋体">/&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: teal; font-family: 宋体">&lt;/</span> <span style="color: #3f7f7f; font-family: 宋体">action</span> <span style="color: teal; font-family: 宋体">&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: teal; font-family: 宋体">&lt;</span> <span style="color: #3f7f7f; font-family: 宋体">plug-in </span><span style="color: #7f007f; font-family: 宋体">className</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"org.springframework.web.struts.ContextLoaderPlugIn"</span> <span style="color: teal; font-family: 宋体">&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: black; font-family: 宋体">&nbsp;&nbsp;&nbsp; </span><span style="color: teal; font-family: 宋体">&lt;</span> <span style="color: #3f7f7f; font-family: 宋体">set-property </span><span style="color: #7f007f; font-family: 宋体">property</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"contextConfigLocation"</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: #2a00ff; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #7f007f; font-family: 宋体">value</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"/WEB-INF/action-servlets.xml"</span> <span style="color: teal; font-family: 宋体">/&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: teal; font-family: 宋体">&lt;/</span> <span style="color: #3f7f7f; font-family: 宋体">plug-in</span> <span style="color: teal; font-family: 宋体">&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="color: #2a00ff; font-family: 宋体">action-servlets.xml</span> <span style="font-family: 宋体">（配置文件格式和spring配置一样）中：</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: teal; font-family: 宋体">&lt;</span> <span style="color: #3f7f7f; font-family: 宋体">beans</span> <span style="color: teal; font-family: 宋体">&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: black; font-family: 宋体">&nbsp;&nbsp;&nbsp; </span><span style="color: teal; font-family: 宋体">&lt;</span> <span style="color: #3f7f7f; font-family: 宋体">bean </span><span style="color: #7f007f; font-family: 宋体">name</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"/portalAction"</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: #2a00ff; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #7f007f; font-family: 宋体">class</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"com.cn.lively.action.PortalMainAction"</span> <span style="color: teal; font-family: 宋体">&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: black; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: teal; font-family: 宋体">&lt;</span> <span style="color: #3f7f7f; font-family: 宋体">property </span><span style="color: #7f007f; font-family: 宋体">name</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"portalService"</span> <span style="color: teal; font-family: 宋体">&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: black; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: teal; font-family: 宋体">&lt;</span> <span style="color: #3f7f7f; font-family: 宋体">ref </span><span style="color: #7f007f; font-family: 宋体">bean</span> <span style="color: black; font-family: 宋体">=</span> <span style="color: #2a00ff; font-family: 宋体">"portalService" </span><span style="color: teal; font-family: 宋体">/&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: black; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: teal; font-family: 宋体">&lt;/</span> <span style="color: #3f7f7f; font-family: 宋体">property</span> <span style="color: teal; font-family: 宋体">&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="color: black; font-family: 宋体">&nbsp;&nbsp;&nbsp; </span><span style="color: teal; font-family: 宋体">&lt;/</span> <span style="color: #3f7f7f; font-family: 宋体">bean</span> <span style="color: teal; font-family: 宋体">&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="color: teal; font-family: 宋体">&lt;/</span> <span style="color: #3f7f7f; font-family: 宋体">beans</span> <span style="color: teal; font-family: 宋体">&gt;</span> </p>
<p style="margin: 0cm 0cm 0pt 18pt; text-indent: -18pt; tab-stops: list 18.0pt"><span style="font-family: 宋体">2.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体">WebApplicationContextUtils.getRequiredWebApplicationContext</span> <span style="font-family: 宋体">：在action中获得spring的bean，</span> </p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="font-family: 宋体">public Object </span><span style="color: black; font-family: 宋体">getService</span> <span style="font-family: 宋体">(String name) {&nbsp;&nbsp; </span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="font-family: 宋体">&nbsp;&nbsp;&nbsp; ApplicationContext </span><span style="color: black; font-family: 宋体">wac</span> <span style="font-family: 宋体">=&nbsp;&nbsp;&nbsp;&nbsp; WebApplicationContextUtils.getRequiredWebApplicationContext(servlet.getServletContext());&nbsp;&nbsp; </span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="font-family: 宋体">&nbsp;&nbsp;&nbsp; return </span><span style="color: black; font-family: 宋体">wac</span> <span style="font-family: 宋体">.getBean(name);&nbsp;&nbsp; </span></p>
<p style="margin: 0cm 0cm 0pt; text-align: left" align="left"><span style="font-family: 宋体">}&nbsp;&nbsp; </span></p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">这种方式没有在struts里边加入spring的plugin，实际上是使用了依赖查找来获得对象，并且在servlet代码中硬编码了应用对象的bean名字。</span> </p>
<p style="margin: 0cm 0cm 0pt"><strong><span style="color: fuchsia; font-family: 宋体">附：</span> </strong></p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">感觉一个国内小型项目（周期半年左右）的开发，完美的团队大概四个人左右就够了，</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">A</span> <span style="font-family: 宋体">：前期框架设计 + 开发过程中不断改进完美整个框架，角色——架构师</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">B</span> <span style="font-family: 宋体">：前期需求调研 + 开发过程中负责技术难度比较大的模块开发，角色——程序员</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">C</span> <span style="font-family: 宋体">：前期需求调研负责人 + 开发过程中负责业务逻辑复杂的模块开发，角色——项目负责人</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">D</span> <span style="font-family: 宋体">：前期需求调研 + 开发过程中负责模块开发，角色——程序员</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">同时B、C负责共同解决开发中出现的技术和业务问题，C负责控制项目进度，</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">项目后期，B、C、D进行交叉测试，A负责review代码。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">如果公司已经比较成熟的框架（即基本系统管理模块 + 代码自动生成），那么角色A可以省略，只需要B、C、D三个人即可进行项目开发，其中角色B在开发中担当一部分A的角色。</span> </p>
<p style="margin: 0cm 0cm 0pt"><span style="font-family: 宋体">甚至可以只由B、C两个人进行开发，把角色D的工作分担到B、C身上，B侧重技术，C侧重业务逻辑。</span> </p>
<img src ="http://www.blogjava.net/WshmAndLily/aggbug/145588.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/WshmAndLily/" target="_blank">semovy</a> 2007-09-16 21:10 <a href="http://www.blogjava.net/WshmAndLily/articles/145588.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UML类目及关系</title><link>http://www.blogjava.net/WshmAndLily/articles/135835.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Fri, 10 Aug 2007 06:38:00 GMT</pubDate><guid>http://www.blogjava.net/WshmAndLily/articles/135835.html</guid><wfw:comment>http://www.blogjava.net/WshmAndLily/comments/135835.html</wfw:comment><comments>http://www.blogjava.net/WshmAndLily/articles/135835.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/WshmAndLily/comments/commentRss/135835.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/WshmAndLily/services/trackbacks/135835.html</trackback:ping><description><![CDATA[<div style="MARGIN-TOP: 1px; MARGIN-LEFT: 15px">
<h2><a title=永久链接：UML类目及关系 href="http://galaxystar.javaeye.com/blog/46775"><font color=#444444>UML类目及关系</font></a> </h2>
</div>
<div style="MARGIN-TOP: 10px; MARGIN-LEFT: 15px">
<table width="100%">
    <tbody>
        <tr>
            <td>
            <p><font face=Arial>类与类之间的关系对于理解面向对象具有很重要的作用，以前在面试的时候也经常被问到这个问题，在这里我就介绍一下。<br>类与类之间存在以下关系:<br><strong><font color=#3366ff>(1)泛化(Generalization)<br>(2)关联(Association)<br>(3)依赖(Dependency)<br>(4)聚合(Aggregation)</font></strong></font> </p>
            <p><font face=Arial><strong>UML图与应用代码例子:</strong> <br><strong><font color=#ff9900 size=4><font color=#3366ff>1.泛化(Generalization)</font> <br></font><font color=#339966 size=3>[泛化]</font> <br></strong>表示类与类之间的继承关系，接口与接口之间的继承关系，或类对接口的实现关系。一般化的关系是从子类指向父类的，与继承或实现的方法相反。<br><font color=#339966 size=3><strong>[具体表现]<br></strong></font><font color=#ff0000>父类</font> 父类实例＝new <font color=#ff0000>子类</font>()<br><strong><font color=#339966 size=3>[UML图](图1.1)<br></font><img alt="" src="http://seagar.javaeye.com/upload/picture/pic/1320/10bfdb9d-ed2d-4226-bab2-f814d2e10a82.jpg"><br></strong><font face=Arial><font color=#339966><strong>图1.1</strong></font><strong>Animal类与Tiger类,Dog类的泛化关系<br></strong></font><br><strong><font color=#339966 size=3>[代码表现]</font><br><br></strong></font></p>
            <div class=dp-highlighter>
            <div class=bar><strong></strong></div>
            <ol class=dp-j>
                <li class=alt><span><span class=keyword><font color=#993333>class</font></span> <span><strong>&nbsp;Animal{} &nbsp;&nbsp;</strong> </span></span><strong></strong>
                <li class=""><span></span><span class=keyword><font color=#993333>class</font></span> <strong><span>&nbsp;Tiger&nbsp;</span> <span class=keyword><font color=#993333>extends</font></span> <span>&nbsp;Animal{} &nbsp;&nbsp;</span> </strong>
                <li class=alt><span></span><span class=keyword><font color=#993333>public</font></span> <strong><span>&nbsp;</span> <span class=keyword><font color=#993333>class</font></span> <span>&nbsp;Test &nbsp;&nbsp;</span> </strong>
                <li class=""><strong><span>{ &nbsp;&nbsp;</span> </strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class=keyword><font color=#993333>public</font></span> <span>&nbsp;</span> <span class=keyword><font color=#993333>void</font></span> <span>&nbsp;test() &nbsp;&nbsp;</span> </strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;</span> </strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Animal&nbsp;a=</span> <span class=keyword><font color=#993333>new</font></span> <span>&nbsp;Tiger(); &nbsp;&nbsp;</span> </strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</span> </strong>
                <li class=alt><strong><span>}&nbsp;&nbsp;</span> </strong></li>
            </ol>
            </div>
            <br><font face=Arial><strong><font color=#3366ff size=4>2.依赖(Dependency)</font> <br></strong><font color=#339966 size=3><strong>[依赖]<br></strong></font>对于两个相对独立的对象，当一个对象负责构造另一个对象的实例，或者依赖另一个对象的服务时，这两个对象之间主要体现为依赖关系。<br><font color=#339966 size=3><strong>[具体表现]<br></strong></font>依赖关系表现在<font color=#ff0000>局部变量</font>，<font color=#ff0000>方法的参数</font>，以及对<font color=#ff0000>静态方法的调用</font><br><font color=#339966 size=3><strong>[现实例子]<br></strong></font>比如说你要去拧螺丝，你是不是要借助(也就是依赖)螺丝刀(Screwdriver)来帮助你完成拧螺丝(screw)的工作<br><font color=#339966 size=3><strong>[UML表现](图1.2)</strong></font><br>
            <p align=left><strong><img alt="" src="http://seagar.javaeye.com/upload/picture/pic/1319/ec7bca6c-c01a-4772-a91b-3a695773ddfb.jpg"></strong></p>
            <p align=left><br><font face=Arial><strong><font color=#339966>图1.2 </font>Person类与Screwdriver类的依赖关系</strong><br><font face=Arial><font color=#339966 size=3><strong><br>[代码表现] </strong></font></font></font></p>
            <div class=dp-highlighter>
            <div class=bar><strong></strong></div>
            <ol class=dp-j>
                <li class=alt><span><span class=keyword><font color=#993333>public</font></span><strong><span>&nbsp;</span><span class=keyword><font color=#993333>class</font></span><span>&nbsp;Person{ &nbsp;&nbsp;</span></strong></span><strong></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=comment><font color=#666666>/**&nbsp;拧螺丝&nbsp;*/</font></span><span>&nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>public</font></span><span>&nbsp;</span><span class=keyword><font color=#993333>void</font></span><span>&nbsp;screw(Screwdriver&nbsp;screwdriver){ &nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;screwdriver.screw(); &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>}&nbsp;&nbsp;</span></strong></li>
            </ol>
            </div>
            <br><font face=Arial><strong><font color=#3366ff size=4>3.关联(Association)</font><br></strong><font color=#339966 size=3><strong>[关联]<br></strong></font>对于两个相对独立的对象，当一个对象的实例与另一个对象的一些特定实例存在固定的对应关系时，这两个对象之间为关联关系。<br><font color=#339966 size=3><strong>[具体表现]<br></strong></font>关联关系是使用<font color=#ff0000>实例变量</font>来实现<br><font color=#339966 size=3><strong>[现实例子]<br></strong></font>比如客户和订单，每个订单对应特定的客户，每个客户对应一些特定的订单；再例如公司和员工，每个公司对应一些特定的员工，每个员工对应一特定的公司<br><strong><font color=#339966 size=3>[UML图] (图1.3)<br></font><img alt="" src="http://seagar.javaeye.com/upload/picture/pic/1318/d4b10677-364d-4c34-beb7-416f8e835d8c.jpg"><br><font face=Arial><strong><font color=#339966>图1.3 </font></strong>公司和员工的关联关系</font></strong></font><br><font face=Arial><strong><br><font color=#339966 size=3>[代码表现]</font></strong>
            <div class=dp-highlighter>
            <div class=bar><strong></strong></div>
            <ol class=dp-j>
                <li class=alt><span><span class=keyword><font color=#993333>public</font></span><strong><span>&nbsp;</span><span class=keyword><font color=#993333>class</font></span><span>&nbsp;Company{ &nbsp;&nbsp;</span></strong></span><strong></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>private</font></span><span>&nbsp;Employee&nbsp;employee; &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>public</font></span><span>&nbsp;Employee&nbsp;getEmployee(){ &nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>return</font></span><span>&nbsp;employee; &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>public</font></span><span>&nbsp;</span><span class=keyword><font color=#993333>void</font></span><span>&nbsp;setEmployee(Employee&nbsp;employee){ &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>this</font></span><span>.employee=employee; &nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=comment><font color=#666666>//公司运作 </font></span><span>&nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>public</font></span><span>&nbsp;</span><span class=keyword><font color=#993333>void</font></span><span>&nbsp;run(){ &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;employee.startWorking(); &nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>}&nbsp;&nbsp;</span></strong></li>
            </ol>
            </div>
            </font></font><font face=Arial><strong><font color=#3366ff size=4>(4)聚合（Aggregation）</font> <br><font color=#339966 size=3>[聚合]<br></font></strong>当对象A被加入到对象B中，成为对象B的组成部分时，对象B和对象A之间为聚集关系。聚合是关联关系的一种，是较强的关联关系，强调的是<font color=#ff0000>整体</font>与<font color=#ff0000>部分</font>之间的关系。<font color=#ff0000>类似于将本职的工作委托给其他类</font><br><font color=#339966 size=3><strong>[具体表现]<br></strong></font>与关联关系一样，聚合关系也是通过<font color=#ff0000>实例变量</font>来实现这样关系的。关联关系和聚合关系来语法上是没办法区分的，从<font color=#ff0000>语义</font>上才能<font color=#ff0000>更好的区分</font>两者的区别。<br><font color=#339966 size=3><strong>[关联与聚合的区别]</strong></font><br>(1)关联关系所涉及的两个对象是处在同一个层次上的。比如人和自行车就是一种关联关系，而不是聚合关系，因为人不是由自行车组成的。<br>聚合关系涉及的两个对象处于不平等的层次上，一个代表整体，一个代表部分。比如电脑和它的显示器、键盘、主板以及内存就是聚集关系，因为主板是电脑的组成部分。<br>(2)对于具有聚集关系（尤其是强聚集关系）的两个对象，整体对象会制约它的组成对象的生命周期。部分类的对象不能单独存在，它的生命周期依赖于整体类的 对象的生命周期，当整体消失，部分也就随之消失。比如张三的电脑被偷了，那么电脑的所有组件也不存在了，除非张三事先把一些电脑的组件（比如硬盘和内存） 拆了下来。<br><font color=#339966 size=3><strong>[UML图](图1.4)</strong></font><br><strong><img alt="" src="http://seagar.javaeye.com/upload/picture/pic/1326/7032798b-36ca-4b89-a462-97ba056cbe48.jpg"><br><font face=Arial><strong><font color=#339966>图1.3 </font><font color=#000000>电脑和组件的聚合关系</font></strong></font><br><br><font face=Arial><font color=#339966 size=3><strong>[代码表现]</strong></font></font></strong>
            <div class=dp-highlighter>
            <ol class=dp-j>
                <li class=alt><span><span class=keyword><font color=#993333>public</font></span><strong><span>&nbsp;</span><span class=keyword><font color=#993333>class</font></span><span>&nbsp;Computer{ &nbsp;&nbsp;</span></strong></span><strong></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>private</font></span><span>&nbsp;CPU&nbsp;cpu; &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>public</font></span><span>&nbsp;CPU&nbsp;getCPU(){ &nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>return</font></span><span>&nbsp;cpu; &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>public</font></span><span>&nbsp;</span><span class=keyword><font color=#993333>void</font></span><span>&nbsp;setCPU(CPU&nbsp;cpu){ &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>this</font></span><span>.cpu=cpu; &nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=comment><font color=#666666>//开启电脑 </font></span><span>&nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=keyword><font color=#993333>public</font></span><span>&nbsp;</span><span class=keyword><font color=#993333>void</font></span><span>&nbsp;start(){ &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class=comment><font color=#666666>//cpu运作 </font></span><span>&nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cpu.run(); &nbsp;&nbsp;</span></strong>
                <li class=alt><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</span></strong>
                <li class=""><strong><span>}&nbsp;&nbsp;</span></strong></li>
            </ol>
            </div>
            <br><br><font face=Arial color=#99cc00><strong>[参考资料]<br>1.《Java与模式》(阎宏 编著) 第2章 统一建模语言UML简介<br><br><br><br></strong><font color=#ff0000>最终的判别可以以内存结构为区分，比如关联与依赖比较难分别，那么，你可以判断，某个对象是在当前类里被实例的还是，只传了引用！如果是引用，则关联，否则就是依赖！比如<br>public class Test {<br>private B b;<br>private A a;<br>public void exec() {<br>&nbsp;&nbsp;&nbsp; A a = new A();<br>&nbsp;&nbsp;&nbsp; b.exec();<br>}<br><br>//a , b 的getter,setter省略<br>}<br>其中A类对象a就是依赖，因为a对象的内存空间被创建在Test</font></font></font><font face=Verdana> </font><font face=Arial color=#99cc00><font color=#ff0000><font face=Arial>这个</font> </font></font><font face=Arial><font face=Arial color=#99cc00><font color=#ff0000>类里<br>而B类的b对象则是引用！<br></font><strong></strong></font></font></td>
        </tr>
    </tbody>
</table>
</div>
<img src ="http://www.blogjava.net/WshmAndLily/aggbug/135835.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/WshmAndLily/" target="_blank">semovy</a> 2007-08-10 14:38 <a href="http://www.blogjava.net/WshmAndLily/articles/135835.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>统一建模语言UML </title><link>http://www.blogjava.net/WshmAndLily/articles/120983.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Wed, 30 May 2007 12:46:00 GMT</pubDate><guid>http://www.blogjava.net/WshmAndLily/articles/120983.html</guid><wfw:comment>http://www.blogjava.net/WshmAndLily/comments/120983.html</wfw:comment><comments>http://www.blogjava.net/WshmAndLily/articles/120983.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/WshmAndLily/comments/commentRss/120983.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/WshmAndLily/services/trackbacks/120983.html</trackback:ping><description><![CDATA[统一建模语言UML <br><br>软件工程领域在1995年至1997年取得了前所未有的进展,其成果超过软件工程领域过去15年来的成就总和。其中最重要的、具有划时代重大意义的成果之一就是统一建模语言(UML:Unified Modeling Language)的出现。 <br><br>在世界范围内,至少在近10年内,UML将是面向对象技术领域内占主导地位的标准建模语言。采用UML作为我国统一的建模语言是完全必要的:首先,过去数十种面向对象的建模语言都是相互独立的,而UML可以消除一些潜在的不必要的差异,以免用户混淆;其次,通过统一语义和符号表示,能够稳定我国的面向对象技术市场,使项目根植于一个成熟的标准建模语言,从而可以大大拓宽所研制与开发的软件系统的适用范围,并大大提高其灵活程度。 <br><br>统一建模语言（UML）是用来对软件密集系统进行描述、构造、视化和文档编制的一种语言。 <br><br>首先，也是最重要的一点，统一建模语言融合了Booch、OMT和OOSE方法中的概念，它是可以被上述及其他方法的使用者广泛采用的一门简单、一致、通用的建模语言。 <br><br>其次，统一建模语言扩展了现有方法的应用范围。特别值得一提的是，UML的开发者们把并行分布式系统的建模作为UML的设计目标，也就是说，UML具有处理这类问题的能力。 <br><br>第三，统一建模语言是标准的建模语言，而不是一个标准的开发流程。虽然UML的应用必然以系统的开发流程为背景，但根据我们的经验，不同的组织，不同的应用领域需要不同的开发过程。举个例子来说，开发错综复杂的软件是非常有趣的工作，但开发这种软件与构造严格实时的航空电子系统是大不一样的，后者是性命攸关的大事。因此我们首先把精力集中在设计通用的元模型上（统一不同方法的语义），其次是建立通用的表示法（提供对这些语义的形象化的表达）。虽然UML的开发者们将继续倡导从用例驱动到体系结构为中心最后反复改进、不断添加的软件开发过程，但实际上设计标准的开发流程并不是非常必要的。 <br><br>UML是一种定义良好、易于表达、功能强大且普遍适用的建模语言。它溶入了软件工程领域的新思想、新方法和新技术。它的作用域不限于支持面向对象的分析与设计,还支持从需求分析开始的软件开发的全过程。 <br><br>面向对象技术和UML的发展过程可用上图来表示,标准建模语言的出现是其重要成果。在美国,截止1996年10月,UML获得了工业界、科技界和应用界的广泛支持,已有700多个公司表示支持采用UML作为建模语言。1996年底,UML已稳占面向对象技术市场的85%,成为可视化建模语言事实上的工业标准。1997年11月17日,OMG采纳UML 1.1作为基于面向对象技术的标准建模语言。UML代表了面向对象方法的软件开发技术的发展方向,具有巨大的市场前景,也具有重大的经济价值和国防价值。 <br><br>标准建模语言UML的内容 <br><br>首先,UML融合了Booch、OMT和OOSE方法中的基本概念,而且这些基本概念与其他面向对象技术中的基本概念大多相同,因而,UML必然成为这些方法以及其他方法的使用者乐于采用的一种简单一致的建模语言;其次,UML不仅仅是上述方法的简单汇合,而是在这些方法的基础上广泛征求意见,集众家之长,几经修改而完成的,UML扩展了现有方法的应用范围;第三,UML是标准的建模语言,而不是标准的开发过程。尽管UML的应用必然以系统的开发过程为背景,但由于不同的组织和不同的应用领域,需要采取不同的开发过程。 <br><br>作为一种建模语言,UML的定义包括UML语义和UML表示法两个部分。 <br><br>(1) UML语义 描述基于UML的精确元模型定义。元模型为UML的所有元素在语法和语义上提供了简单、一致、通用的定义性说明,使开发者能在语义上取得一致,消除了因人而异的最佳表达方法所造成的影响。此外UML还支持对元模型的扩展定义。 <br><br>(2) UML表示法 定义UML符号的表示法,为开发者或开发工具使用这些图形符号和文本语法为系统建模提供了标准。这些图形符号和文字所表达的是应用级的模型,在语义上它是UML元模型的实例。 <br><br>标准建模语言UML的重要内容可以由下列五类图(共9种图形)来定义: <br><br>&#183;第一类是用例图,从用户角度描述系统功能,并指出各功能的操作者。 <br><br>&#183;第二类是静态图(Static diagram),包括类图、对象图和包图。其中类图描述系统中类的静态结构。不仅定义系统中的类,表示类之间的联系如关联、依赖、聚合等,也包括类的内部结构(类的属性和操作)。类图描述的是一种静态关系,在系统的整个生命周期都是有效的。对象图是类图的实例,几乎使用与类图完全相同的标识。他们的不同点在于对象图显示类的多个对象实例,而不是实际的类。一个对象图是类图的一个实例。由于对象存在生命周期,因此对象图只能在系统某一时间段存在。包由包或类组成,表示包与包之间的关系。包图用于描述系统的分层结构。 <br><br>&#183;第三类是行为图(Behavior diagram),描述系统的动态模型和组成对象间的交互关系。其中状态图描述类的对象所有可能的状态以及事件发生时状态的转移条件。通常,状态图是对类图的补充。在实用上并不需要为所有的类画状态图,仅为那些有多个状态其行为受外界环境的影响并且发生改变的类画状态图。而活动图描述满足用例要求所要进行的活动以及活动间的约束关系,有利于识别并行活动。 <br><br>&#183;第四类是交互图(Interactive diagram),描述对象间的交互关系。其中顺序图显示对象之间的动态合作关系,它强调对象之间消息发送的顺序,同时显示对象之间的交互;合作图描述对象间的协作关系,合作图跟顺序图相似,显示对象间的动态合作关系。除显示信息交换外,合作图还显示对象以及它们之间的关系。如果强调时间和顺序,则使用顺序图;如果强调上下级关系,则选择合作图。这两种图合称为交互图。 <br><br>&#183;第五类是实现图( Implementation diagram )。其中构件图描述代码部件的物理结构及各部件之间的依赖关系。一个部件可能是一个资源代码部件、一个二进制部件或一个可执行部件。它包含逻辑类或实现类的有关信息。部件图有助于分析和理解部件之间的相互影响程度。 <br><br>配置图定义系统中软硬件的物理体系结构。它可以显示实际的计算机和设备(用节点表示)以及它们之间的连接关系,也可显示连接的类型及部件之间的依赖性。在节点内部,放置可执行部件和对象以显示节点跟可执行软件单元的对应关系。 <br><br>从应用的角度看,当采用面向对象技术设计系统时,首先是描述需求;其次根据需求建立系统的静态模型,以构造系统的结构;第三步是描述系统的行为。其中在第一步与第二步中所建立的模型都是静态的,包括用例图、类图(包含包)、对象图、组件图和配置图等五个图形,是标准建模语言UML的静态建模机制。其中第三步中所建立的模型或者可以执行,或者表示执行时的时序状态或交互关系。它包括状态图、活动图、顺序图和合作图等四个图形,是标准建模语言UML的动态建模机制。因此,标准建模语言UML的主要内容也可以归纳为静态建模机制和动态建模机制两大类。</ca>
<img src ="http://www.blogjava.net/WshmAndLily/aggbug/120983.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/WshmAndLily/" target="_blank">semovy</a> 2007-05-30 20:46 <a href="http://www.blogjava.net/WshmAndLily/articles/120983.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UML基础知识</title><link>http://www.blogjava.net/WshmAndLily/articles/117899.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Wed, 16 May 2007 09:50:00 GMT</pubDate><guid>http://www.blogjava.net/WshmAndLily/articles/117899.html</guid><wfw:comment>http://www.blogjava.net/WshmAndLily/comments/117899.html</wfw:comment><comments>http://www.blogjava.net/WshmAndLily/articles/117899.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/WshmAndLily/comments/commentRss/117899.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/WshmAndLily/services/trackbacks/117899.html</trackback:ping><description><![CDATA[<div class=postTitle><a href="http://blog.donews.com/rocying/archive/2005/08/06/496614.aspx"><u><font color=#800080>UML基础知识 </font></u></a></div>
<div class=postText>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">1.<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">软件工程的</span><span lang=EN-US>5</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个阶段：<strong style="mso-bidi-font-weight: normal">需求分析</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Requirements Capture)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，<strong style="mso-bidi-font-weight: normal">系统分析与设计</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(System Analysis and Design)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，<strong style="mso-bidi-font-weight: normal">实现</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Implement)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，<strong style="mso-bidi-font-weight: normal">测试</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Test)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，<strong style="mso-bidi-font-weight: normal">维护</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Maintenance)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">2.<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span lang=EN-US>UML</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的定义包括</span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>UML</span></strong><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语义</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>UML</span></strong><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">表示法</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">两个部分。</span><span lang=EN-US>UML</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语义描述基于</span><span lang=EN-US>UML</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的精确<strong style="mso-bidi-font-weight: normal">元模型定义</strong>。元模型为</span><span lang=EN-US>UML</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的所有元素在语法和语义上提供了简单、一致和通用的定义性说明。</span><span lang=EN-US>UML</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">表示法，为开发者或开发工具使用图形工具和文本语法为系统建模提供了标准。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">3.<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><span lang=EN-US>UML(Unified Modeling Language)</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">由<strong style="mso-bidi-font-weight: normal">视图</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，<strong style="mso-bidi-font-weight: normal">图</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Diagram)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，<strong style="mso-bidi-font-weight: normal">模型元素</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Model Element)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，<strong style="mso-bidi-font-weight: normal">通用机制</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(General Mechanism)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等组成，还提供了<strong style="mso-bidi-font-weight: normal">扩展机制</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Extension Mechanism)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，使得</span><span lang=EN-US>UML</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语言能够适应一个特殊的方法或者扩充到一个组织或用户。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">a)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">视图</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是表达系统的某一方面特征的</span><span lang=EN-US>UML</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建模元素的子集，由多个<strong style="mso-bidi-font-weight: normal">图</strong>构成，是在某一个抽象层上，对系统的抽象表示。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">b)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是模型元素集的<strong style="mso-bidi-font-weight: normal">图形表示</strong>，通常由<strong style="mso-bidi-font-weight: normal">弧</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(</span></strong><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">关系</span></strong><span lang=EN-US>)</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和<strong style="mso-bidi-font-weight: normal">顶点</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(</span></strong><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其他模型元素</span><span lang=EN-US>)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">相互连接构成。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">c)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">模型元素</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代表面向对象中的类、对象、消息和关系等概念，是构成图的基本概念。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">d)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通用机制</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用于表示其他信息，比如注释、模型元素的语义等。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">4.<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span lang=EN-US>UML</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用模型来描述系统的结构或静态特征，以及行为或动态特征，从不同的视角为系统架构建模，形成不同视角：</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">a)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用例视图</span><span lang=EN-US>(Use Case View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，强调从用户角度看到的或需要的系统功能，是被称为参与者的外部用户所能观察到的系统功能的模型图。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">b)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">逻辑视图</span><span lang=EN-US>(Logical View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，展现系统的静态或结构组成及特征，也被称为<strong style="mso-bidi-font-weight: normal">结构模型视图</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Structural Model View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或者<strong style="mso-bidi-font-weight: normal">静态视图</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Static View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">c)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并发视图</span><span lang=EN-US>(Concurrent View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，体现了系统的动态或者行为特征，也称为<strong style="mso-bidi-font-weight: normal">行为模型视图</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Behavioral Model View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或<strong style="mso-bidi-font-weight: normal">动态视图</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Dynamic View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">d)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组件视图</span><span lang=EN-US>(Component View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，体现了系统实现的结构和行为特征，也称为<strong style="mso-bidi-font-weight: normal">实现模型视图</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Implementation Model View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">e)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">配置视图</span><span lang=EN-US>(Deployment View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，体现了系统实现环境的结构和行为特征，也被称为<strong style="mso-bidi-font-weight: normal">环境模型视图</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Environment Model View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或者<strong style="mso-bidi-font-weight: normal">物理视图</strong></span><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>(Physical View)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">5.<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">视图由图构成，</span><span lang=EN-US>UML</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提供了</span><span lang=EN-US>9</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">种不同的图：</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">a)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用例图</span><span lang=EN-US>(Use Case Diagram)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，描述系统功能；</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">b)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类图</span><span lang=EN-US>(Class Diagram)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，描述系统的静态结构；</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">c)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象图</span><span lang=EN-US>(Object Diagram)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，描述系统在某个时刻的静态结构；</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">d)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">时序图</span><span lang=EN-US>(Sequence Diagram)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，按时间顺序描述系统元素间的交互；</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">e)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">协作图</span><span lang=EN-US>(Collaboration Diagram)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，按照时间和空间顺序描述系统元素间的交互和他们之间的关系；</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">f)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">状态图</span><span lang=EN-US>(State Diagram)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，描述了系统元素的状态条件和响应；</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">g)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">活动图</span><span lang=EN-US>(Activity Diagram)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，描述了系统元素的活动；</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">h)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组件图</span><span lang=EN-US>(Component Diagram)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，描述了实现系统的元素的组织；</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">i)<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">配置图</span><span lang=EN-US>(Deployment Diagram)</span></strong><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，描述了环境元素的配置，并把实现系统的元素映射到配置上。</span></font></font></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">6.<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图和视图之间的对应关系：</span></font></font><span lang=EN-US><br></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face=Tahoma size=2>用户模型视图：用例图</font></span><span lang=EN-US><br></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face=Tahoma size=2>结构模型视图：类图和对象图</font></span><span lang=EN-US><br></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face=Tahoma size=2>行为模型视图：时序图、协作图、状态图和活动图</font></span><span lang=EN-US><br></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face=Tahoma size=2>实现模型视图：组件图</font></span><span lang=EN-US><br></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face=Tahoma size=2>环境模型视图：配置图</font></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><font face=Tahoma><font size=2><span lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">7.<span style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span lang=EN-US>UML</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的两套建模机制，<strong style="mso-bidi-font-weight: normal">静态建模机制</strong>和<strong style="mso-bidi-font-weight: normal">动态建模机制</strong>。静态建模机制包括用例图、类图、对象图、包、组件图和配置图；动态建模机制包括消息、状态图、时序图、协作图、活动图。</span></font></font></p>
</div>
<img src ="http://www.blogjava.net/WshmAndLily/aggbug/117899.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/WshmAndLily/" target="_blank">semovy</a> 2007-05-16 17:50 <a href="http://www.blogjava.net/WshmAndLily/articles/117899.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UML概述</title><link>http://www.blogjava.net/WshmAndLily/articles/115715.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Mon, 07 May 2007 07:46:00 GMT</pubDate><guid>http://www.blogjava.net/WshmAndLily/articles/115715.html</guid><wfw:comment>http://www.blogjava.net/WshmAndLily/comments/115715.html</wfw:comment><comments>http://www.blogjava.net/WshmAndLily/articles/115715.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/WshmAndLily/comments/commentRss/115715.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/WshmAndLily/services/trackbacks/115715.html</trackback:ping><description><![CDATA[<p><a name=1><span><span>1.</span></span></a><span><span><span>背景知识</span></span></span><span></span></p>
<p><span>1997</span><span>年，</span><span>OMG</span><span>组织（</span><span>Object Management Group</span><span>对象管理组织）发布了统一建模语言（</span><span>Unified Modeling Language</span><span>，</span><span>UML</span><span>）。</span><span>UML</span><span>的主要创始人是</span><span>Jim Rumbaugh</span><span>、</span><span>Ivar Jacobson</span><span>和</span><span>Grady Booch ,UML</span><span>的目标之一就是为开发团队提供标准通用的设计语言来开发和构建计算机应用。</span><span>UML</span><span>提出了一套</span><span>IT</span><span>专业人员期待多年的统</span> <span>一的标准建模符号。通过使用</span><span>UML</span><span>，这些人员能够阅读和交流系统架构和设计规划</span><span>, UML</span><span>符号集只是一种语言而不是一种方法学</span><span>. 2003</span><span>年，</span><span>UML</span><span>已经获得了业界的认同</span><span>.</span></p>
<p>&nbsp;</p>
<p><span>2.</span><span>简述</span></p>
<p><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>UML</span><span>捕捉了软件系统有关决策和理解</span><span>,</span><span>用来理解、设计、浏览、配置、维护以及控制系统得信息</span><span>.UML</span><span>包括语义概念、标记符号和指南</span><span>,</span><span>据有静态、动态、环境上和组织性的部分</span><span>.</span></p>
<p>&lt;!--[if !supportLists]--&gt;<span><span>I．<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span>&lt;!--[endif]--&gt;<span>UML</span><span>捕捉静态结构和动态行为的信息。系统建模成独立对象的集合以及它们交互和实现。静态结构定义各种对象和实现已经它们的关系，动态行为定义了对象间的通讯。可以从不同视角进行建模，以不同视角理解系统。</span></p>
<p>&lt;!--[if !supportLists]--&gt;<span><span>II．<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span>&lt;!--[endif]--&gt;<span>UML</span><span>可以用包来组织模型结构</span></p>
<p>&nbsp;</p>
<p><span>3</span><span>．目标</span></p>
<p><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>UML</span><span>不是完整的开发方法，它不包括逐步的开发流程。但</span><span>UML</span><span>包括了所有必要的概念来解决现代迭代过程中解决用例驱动的需求。</span></p>
<p>&nbsp;</p>
<p><span>4</span><span>．</span><span>UML</span><span>概念范围</span></p>
<p><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>I</span><span>．</span><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span>静态结构</span></p>
<p><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>II</span><span>．</span><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span>动态行为</span></p>
<p>&lt;!--[if !supportLists]--&gt;<span><span>III．<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span>&lt;!--[endif]--&gt;<span><span> &nbsp;&nbsp;&nbsp; </span></span><span>实现构造</span></p>
<p>&lt;!--[if !supportLists]--&gt;<span><span>IV．<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span>&lt;!--[endif]--&gt;<span><span>&nbsp;&nbsp;&nbsp; </span></span><span>模型组织</span></p>
<p>&lt;!--[if !supportLists]--&gt;<span><span>V．<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </span></span></span>&lt;!--[endif]--&gt;<span><span> &nbsp;&nbsp; </span></span><span>扩展机制</span></p>
<p><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br></span></p>
<p><span>5.&nbsp;&nbsp; UML</span><span>视图</span></p>
<p><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>UML</span><span>视图可以分为三个领域：<span>结构型分类、动态行为和模型管理</span></span></p>
<p><span>I</span><span>．结构性分类包括静态视图、用例视图和实现视图。它描述了系统中事物和事物之间的关系，包括类、用例、构件和节点，为构建动态行为提供了基础。</span></p>
<p><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>II</span><span>．动态行为包括状态机视图、活动图和交互图。它描述了系统时间上的行为</span></p>
<p><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>III</span><span>．模型管理，用包来组织模型，特殊的包包括模型和子系统，模型视图和其它视图交迭，为团队工作和配置控制把它们组织起来。</span></p>
<p><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>IV</span><span>．扩展，包括约束、版型和标签值。</span></p>
<img src ="http://www.blogjava.net/WshmAndLily/aggbug/115715.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/WshmAndLily/" target="_blank">semovy</a> 2007-05-07 15:46 <a href="http://www.blogjava.net/WshmAndLily/articles/115715.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UML必懂！</title><link>http://www.blogjava.net/WshmAndLily/articles/106217.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Sun, 25 Mar 2007 07:17:00 GMT</pubDate><guid>http://www.blogjava.net/WshmAndLily/articles/106217.html</guid><wfw:comment>http://www.blogjava.net/WshmAndLily/comments/106217.html</wfw:comment><comments>http://www.blogjava.net/WshmAndLily/articles/106217.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/WshmAndLily/comments/commentRss/106217.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/WshmAndLily/services/trackbacks/106217.html</trackback:ping><description><![CDATA[1、活动图、类图用在详细设计。（详细设计和概要设计有些时候不是分的那么细） <br />2、顺序图、类图、构件图用在概要设计。 <br />3、用例图、状态图是给客户看的。 <br />4、顺序图是根据类图来画的，顺序图中的对象是类图中的类的实例，顺序图中一个对象 <br />指向另一个对象的方法是这个对象的方法。 <br /><br /><br /><br />5、三层结构(1)界面类 我做好了一些按钮、文本框、标签等，分给一个初级程序员就可以， <br />把界面规划好就行，对里面的业务不必关心。 <br />(2)业务类 这就要给一个高级程序员来做，主要是哪些类实现哪些方法就行。 <br />(3)实体类 用业务来调用实体，实体就是实实在在的东西。 <br />注意:在界面类和业务类之间，有这样一个，用中间的接口人， <br />可以是高级程序员,他要用struts把界面和业务联系起来。 <br />UML的课程总结 <br /><br />UML是干什么的,是用来表达我们思想的,我们的面向对象的思想. <br />想一想:我们来到这个班,是为了锻炼我们怎么去独立思考,怎么去工作的, <br />在设计的时候,要有一个设计的理念,和设计的思想, <br />只有你自己真的动脑去想了,那才是你自己的,老师告诉你, <br />那是老师的,不是你的. <br />说一下九个图: <br /><br />一、需求阶段:1、用例图 (1)你画完了，主要是用户能否看懂。 <br />(2)你画的用例图里是不是覆盖了用户需求的每一个功能和要求。 <br />　　 2、状态图 (1)在这个状态很重要的情况下，要把它画出来。 <br />(2)很强调状态时需要画它。 <br />二、设计阶段包括（概要设计和详细设计分公司而言） <br />　　　　　　 1、概要设计(1)构件图 @强调软件之间的和部署图形成对比。 <br />(2)时序图 @宽广的时候用在概要设计。 <br />(3)类图 @ <br />(4)协作图 @ <br />　　 2、详细设计(1)类图 @在这里面一定要写详细了，让编码人员看完，伪代码就能出来（伪代码是指一般用代码的格式表示程序执行过程和算法，但不能在编译器上通过编译的代码，目的是为了展示程序的执行过程。） <br />@每个类的方法，属性都要写出来。 <br />(2)活动图 @逻辑复杂的时候要用到它，如果想练习的话，可以用随机抽题这个来练。 <br />(3)时序图 @主要强调顺序，就是必须按这个顺序来的。 <br />(4)部署图 @是强调硬件之间的和上面的构件图形成对比。 <br />重点：1、用例图 <br />2、类图 <br />3、时序图 <br />4、活动图 ·是给一个编码人员就可以做出来的东西，每一句一句的翻译过来。不需要知道太多。 <br /><br />还有一个要说的是：计划进度表。 <br />(1)需求从多长时间到多长时间。 <br />(2)设计从多长时间到多长时间。 <br />(3)编码从多长时间到多长时间。 <br /><br /><p align="right">摘自 <a href="http://chenkaituo.blog.ccidnet.com/blog/ccid/do_showone/tid_134022.html" target="_blank"><font color="#000000">chenkaituo</font></a> 的BLOG</p><img src ="http://www.blogjava.net/WshmAndLily/aggbug/106217.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/WshmAndLily/" target="_blank">semovy</a> 2007-03-25 15:17 <a href="http://www.blogjava.net/WshmAndLily/articles/106217.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>