﻿<?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>C++博客-aa19870406-随笔分类-UML</title><link>http://www.cppblog.com/aa19870406/category/17013.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 30 May 2011 13:13:31 GMT</lastBuildDate><pubDate>Mon, 30 May 2011 13:13:31 GMT</pubDate><ttl>60</ttl><item><title>UML类图中的几种关系</title><link>http://www.cppblog.com/aa19870406/archive/2011/05/30/147715.html</link><dc:creator>MrRightLeft</dc:creator><author>MrRightLeft</author><pubDate>Mon, 30 May 2011 13:08:00 GMT</pubDate><guid>http://www.cppblog.com/aa19870406/archive/2011/05/30/147715.html</guid><wfw:comment>http://www.cppblog.com/aa19870406/comments/147715.html</wfw:comment><comments>http://www.cppblog.com/aa19870406/archive/2011/05/30/147715.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/aa19870406/comments/commentRss/147715.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/aa19870406/services/trackbacks/147715.html</trackback:ping><description><![CDATA[<div>UML类图中的&#8220;关联关系(association)&#8221;、&#8220;聚合关系(aggregation)"、&#8221;合成关系(composition"和&#8220;依赖关系(depedency)。<br /><br /><span style="font-family: 宋体; font-size: 12px; line-height: 20px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><strong>(1)关联关系 (association)</strong>：</span><div style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-family: 宋体; font-size: 12px; line-height: 20px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">&nbsp;&nbsp; (1)关联关系是类与类之间的联结，它使一个类知道另一个类的属性和方法。<br />&nbsp; &nbsp;(2)关联可以是双向的，也可以是单向的。双向的关联可以有两个箭头或者没有箭头，单向的关联有一个箭头。</span></div><div style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a href="http://www.uml.org.cn/oobject/201012233.asp"><br /></a><div style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "></div>(2)<span style="font-family: 宋体; font-size: 12px; line-height: 20px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><strong>&nbsp;聚合关系 (aggregation)</strong></span><span style="font-family: 宋体; font-size: 12px; line-height: 20px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">：</span></div><div style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-family: 宋体; font-size: 12px; line-height: 20px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">&nbsp; &nbsp;1、聚合关系是关联关系的一种，是强的关联关系。<br />&nbsp;&nbsp; 2、聚合是整体和部分之间的关系，例如汽车由引擎、轮胎以及其它零件组成。<br />&nbsp;&nbsp; 3、聚合关系也是通过成员变量来实现的。但是，关联关系所涉及的两个类处在同一个层次上，而聚合关系 &nbsp; &nbsp; &nbsp; 中，两个类处于不同的层次上，一个代表整体，一个代表部分。<br />&nbsp;&nbsp; 4、关联与聚合仅仅从 Java 或 C++ 语法上是无法分辨的，必须考察所涉及的类之间的逻辑关系。<br /><strong>(3)合成关系 (composition)：</strong><div style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;&nbsp; 1、合成关系是关联关系的一种，是比聚合关系还要强的关系。<br />&nbsp;&nbsp; 2、它要求普通的聚合关系中代表整体的对象负责代表部分的对象的生命周期。<br /><strong>(4)依赖关系 (dependency)：</strong><div style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp; &nbsp;1、依赖关系也是类与类之间的联结<br />&nbsp;&nbsp; 2、依赖总是单向的。<br />&nbsp; &nbsp;3、依赖关系在 Java 或 C++ 语言中体现为局部变量、方法的参数或者对静态方法的调用。<br /><br /><div style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a href="http://www.uml.org.cn/oobject/201012233.asp">http://www.uml.org.cn/oobject/201012233.asp</a></div></div></div></span></div></div><img src ="http://www.cppblog.com/aa19870406/aggbug/147715.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/aa19870406/" target="_blank">MrRightLeft</a> 2011-05-30 21:08 <a href="http://www.cppblog.com/aa19870406/archive/2011/05/30/147715.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>