﻿<?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-离弦之ray的技术天空-随笔分类-Model</title><link>http://www.blogjava.net/clraychen/category/26557.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 16 Oct 2007 03:15:30 GMT</lastBuildDate><pubDate>Tue, 16 Oct 2007 03:15:30 GMT</pubDate><ttl>60</ttl><item><title>《UML 面向对象建模与设计》读书笔记1_基本概念_Class Model</title><link>http://www.blogjava.net/clraychen/archive/2007/10/15/152917.html</link><dc:creator>离弦之ray的技术天空</dc:creator><author>离弦之ray的技术天空</author><pubDate>Mon, 15 Oct 2007 03:30:00 GMT</pubDate><guid>http://www.blogjava.net/clraychen/archive/2007/10/15/152917.html</guid><wfw:comment>http://www.blogjava.net/clraychen/comments/152917.html</wfw:comment><comments>http://www.blogjava.net/clraychen/archive/2007/10/15/152917.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/clraychen/comments/commentRss/152917.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/clraychen/services/trackbacks/152917.html</trackback:ping><description><![CDATA[&nbsp;
<h1 class="cjk" align="center">基础概念——<font face="Arial, sans-serif">Class Modeling</font></h1>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif">OO</font>的概念——这就不多说了</p>
<p style="margin-bottom: 0cm"><br />
</p>
<p style="margin-bottom: 0cm">三种模型</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif">class model——</font>描述<font face="Times New Roman, serif">object</font>的结构</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif">state model——</font>描述单个<font face="Times New Roman, serif">object</font>的行为</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif">interaction model——</font>描述<font face="Times New Roman, serif">object</font>之间的互动行为</p>
<p style="margin-bottom: 0cm"><br />
</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><strong style="color: #0000ff">Class Model</strong></font></p>
<p style="margin-bottom: 0cm"><strong>单个的<font face="Times New Roman, serif">class</font>图很简单<br />
</strong></p>
<p style="margin-bottom: 0cm"><img height="190" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_1.JPG" width="216" border="0" /><br />
首先是类名、然后是属性，最后是方法。</p>
<p style="margin-bottom: 0cm">前面的<font face="Times New Roman, serif">+</font>表示<font face="Times New Roman, serif">public</font>，<font face="Times New Roman, serif">-</font>表示<font face="Times New Roman, serif">private</font>，<font face="Times New Roman, serif">#</font>表示<font face="Times New Roman, serif">protected</font></p>
<p style="margin-bottom: 0cm"><br />
</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><strong>Association<br />
</strong></font></p>
<p style="margin-bottom: 0cm"><img height="155" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_2.JPG" width="365" border="0" /><br />
形式上<font face="Times New Roman, serif">Association</font>就是一根线，表示两个类之间的关系，线上可以标明<font face="Times New Roman, serif">Association</font>的名字，两端可以标上<font face="Times New Roman, serif">multiplicity</font>：<font face="Times New Roman, serif">1</font>表示<font face="Times New Roman, serif">one</font>，<font face="Times New Roman, serif">"1..*"</font>表示<font face="Times New Roman, serif">one or more</font>，<font face="Times New Roman, serif">"3..5"</font>表示<font face="Times New Roman, serif">three to five</font>，</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif">"*"</font>表示<font face="Times New Roman, serif">many</font></p>
<p style="margin-bottom: 0cm">两个类之间可以有多于一个<font face="Times New Roman, serif">Association</font>，但一般不常用</p>
<p style="margin-bottom: 0cm"><br />
</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><strong>Association End Names</strong><br />
</font></p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><img height="155" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_3.JPG" width="459" border="0" /><br />
Association</font>的两端可以标上两个类在这个关系中的角色</p>
<p style="margin-bottom: 0cm">这在两个类的关系中作用可能不是特别明显，但如果相关的双方属于同一个类</p>
<p style="margin-bottom: 0cm"><img height="155" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_4.JPG" width="197" border="0" /><br />
</p>
<p style="margin-bottom: 0cm"><strong><font face="Times New Roman, serif">Association</font>两端可以加很多限制</strong><br />
</p>
<p style="margin-bottom: 0cm"><br />
<img height="155" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_5.JPG" width="396" border="0" /><br />
<img height="155" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_6.JPG" width="396" border="0" /></p>
<p style="margin-bottom: 0cm">等等，还有<font face="Times New Roman, serif">Bags</font>对应于<font face="Times New Roman, serif">sequence</font>，没有先后次序。</p>
<p style="margin-bottom: 0cm"><br />
</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><strong>Qualified Association<br />
</strong></font></p>
<p style="margin-bottom: 0cm"><br />
首先是没有<font face="Times New Roman, serif">Qualified</font>的<br />
</p>
<p style="margin-bottom: 0cm"><img height="136" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_7.JPG" width="409" border="0" /><br />
然后是<font face="Times New Roman, serif">Qualified</font></p>
<p style="margin-bottom: 0cm"><img height="155" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_8.JPG" width="426" border="0" /><br />
</p>
<p style="margin-bottom: 0cm"><br />
</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><strong>N-ary Association</strong></font></p>
<p style="margin-bottom: 0cm"><img height="209" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_9.JPG" width="445" border="0" /><br />
</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><strong>Generalization</strong></font></p>
<p style="margin-bottom: 0cm">具体在编程语言中，就是继承关系<br />
</p>
<p style="margin-bottom: 0cm"><img height="203" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_10.JPG" width="525" border="0" /><br />
很简单不多说</p>
<p style="margin-bottom: 0cm"><br />
</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif">Association-&gt;Aggregation-&gt;Composition</font></p>
<p style="margin-bottom: 0cm"><br />
</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><strong>Aggregation</strong></font>表现的是一种<font face="Times New Roman, serif">part-whole</font>的关系</p>
<p style="margin-bottom: 0cm"><img height="167" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_11.JPG" width="569" border="0" /><br />
</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><strong>Composition</strong><br />
</font></p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><img height="105" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_12.JPG" width="515" border="0" /><br />
Composition</font>与<font face="Times New Roman, serif">Aggregation</font>的区别是<font face="Times New Roman, serif">part</font>只能属于一个<font face="Times New Roman, serif">Assembly</font></p>
<p style="margin-bottom: 0cm">可以说<font face="Times New Roman, serif">Association-&gt;Aggregation-&gt;Composition</font>关系一层强过一层</p>
<p style="margin-bottom: 0cm"><br />
</p>
<p style="margin-bottom: 0cm"><font face="Times New Roman, serif"><strong>Abstract Class</strong> </font>类名用斜体字<br />
</p>
<p style="margin-bottom: 0cm"><img height="102" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_13.JPG" width="164" border="0" /><br />
属性有一种叫做<font face="Times New Roman, serif"><strong>Derived Data</strong></font>，它的意思是这个属性是被其它属性或类导出来的，被其它<font face="Times New Roman, serif">elements</font>所决定，符号是在这个属性前面加上斜杠<br />
</p>
<p style="margin-bottom: 0cm"><img height="144" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_14.JPG" width="165" border="0" /><br />
如上图中，<font face="Times New Roman, serif">age</font>由<font face="Times New Roman, serif">birthdate </font>和 <font face="Times New Roman, serif">currentDate</font>所决定。</p>
<p style="margin-bottom: 0cm">最后一种图示，就是<font face="Times New Roman, serif"><strong>package</strong></font></p>
<p style="margin-bottom: 0cm"><img height="132" alt="" src="http://www.blogjava.net/images/blogjava_net/clraychen/class_15.JPG" width="213" border="0" /><br />
</p>
<img src ="http://www.blogjava.net/clraychen/aggbug/152917.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/clraychen/" target="_blank">离弦之ray的技术天空</a> 2007-10-15 11:30 <a href="http://www.blogjava.net/clraychen/archive/2007/10/15/152917.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>