﻿<?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-决战大数据-随笔分类-Java SE</title><link>http://www.blogjava.net/wxb1988/category/54785.html</link><description>知人者智，自知者明。胜人者有力，自胜者强。</description><language>zh-cn</language><lastBuildDate>Tue, 02 Jun 2015 08:09:54 GMT</lastBuildDate><pubDate>Tue, 02 Jun 2015 08:09:54 GMT</pubDate><ttl>60</ttl><item><title>设计模式</title><link>http://www.blogjava.net/wxb1988/archive/2015/06/02/425453.html</link><dc:creator>wxb1988</dc:creator><author>wxb1988</author><pubDate>Tue, 02 Jun 2015 08:01:00 GMT</pubDate><guid>http://www.blogjava.net/wxb1988/archive/2015/06/02/425453.html</guid><wfw:comment>http://www.blogjava.net/wxb1988/comments/425453.html</wfw:comment><comments>http://www.blogjava.net/wxb1988/archive/2015/06/02/425453.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/wxb1988/comments/commentRss/425453.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wxb1988/services/trackbacks/425453.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Christopher Alexander&nbsp;说过：&#8220;每一个模式描述了一个在我们周围不断重复发生的问题，以及该问题的解决方案的核心。这样，你就能一次又一次地使用该方案而不必做重复劳动&#8221;。模式描述为：在一定环境中解决某一问题的方案，包括三个基本元素--问题，解决方案和环境。阅读类图和对象图请先学习UML创建模式 结构模式 行为模式创建模式：对类的实例化过程的抽象。一些...&nbsp;&nbsp;<a href='http://www.blogjava.net/wxb1988/archive/2015/06/02/425453.html'>阅读全文</a><img src ="http://www.blogjava.net/wxb1988/aggbug/425453.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wxb1988/" target="_blank">wxb1988</a> 2015-06-02 16:01 <a href="http://www.blogjava.net/wxb1988/archive/2015/06/02/425453.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> UML概述与详解</title><link>http://www.blogjava.net/wxb1988/archive/2015/06/02/425452.html</link><dc:creator>wxb1988</dc:creator><author>wxb1988</author><pubDate>Tue, 02 Jun 2015 08:00:00 GMT</pubDate><guid>http://www.blogjava.net/wxb1988/archive/2015/06/02/425452.html</guid><wfw:comment>http://www.blogjava.net/wxb1988/comments/425452.html</wfw:comment><comments>http://www.blogjava.net/wxb1988/archive/2015/06/02/425452.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/wxb1988/comments/commentRss/425452.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wxb1988/services/trackbacks/425452.html</trackback:ping><description><![CDATA[<div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><strong><span style="color: blue;">统一建模语言(UML:Unified Modeling Language)</span></strong></div><div style="font-family: Arial; line-height: 26px; margin-left: 18pt; text-indent: -18pt; background-color: #ffffff;"><strong><span style="color: blue;">1．</span></strong><strong><span style="color: blue;">能够从不同的角度来看待系统的结构，行为，功能（需求）。</span></strong></div><div style="font-family: Arial; line-height: 26px; margin-left: 18pt; text-indent: -18pt; background-color: #ffffff;"><strong><span style="color: blue;">2．</span></strong><strong><span style="color: blue;">能够在不同抽象程度上考虑系统，而仅仅是源代码是不够的。源代码是非常细化的内部结构，不能用来建造复杂的系统。</span></strong></div><table cellspacing="0" cellpadding="0" width="100%" border="0" style="color: #000000; font-family: Arial; font-size: 14px; line-height: 26px; width: 946px; border-collapse: collapse; background-color: #ffffff;"><tbody><tr style="height: 13.75pt;"><td valign="top" width="100%" colspan="2" style="border-width: medium medium 1pt; border-style: none none solid; padding: 0cm 5.4pt; width: 931.625px; border-bottom-color: windowtext; height: 13.75pt;">UML图及其目的</td></tr><tr style="height: 13.3pt;"><td valign="top" width="18%" style="border: medium none; padding: 0cm 5.4pt; width: 160.625px; height: 13.3pt;">当你&#8230;&#8230;</td><td valign="top" width="81%" style="border: medium none; padding: 0cm 5.4pt; width: 756.625px; height: 13.3pt;">使用UML图&#8230;&#8230;</td></tr><tr style="height: 13.3pt;"><td valign="top" width="18%" rowspan="2" style="padding: 0cm 5.4pt; width: 160.625px; height: 13.3pt;">在分析阶段</td><td valign="top" width="81%" style="padding: 0cm 5.4pt; width: 756.625px; height: 13.3pt;">用例图，它们包含和系统交互的实体以及需要实现的功能点。</td></tr><tr style="height: 10.1pt;"><td valign="top" width="81%" style="padding: 0cm 5.4pt; width: 756.625px; height: 10.1pt;">活动图，它们将焦点集中于问题域（人们以及其它主体工作的实际空间，程序的主题域）的工作流而不是程序的逻辑流。</td></tr><tr style="height: 10.1pt;"><td valign="top" width="18%" style="padding: 0cm 5.4pt; width: 160.625px; height: 10.1pt;">观察对象交互</td><td valign="top" width="81%" style="padding: 0cm 5.4pt; width: 756.625px; height: 10.1pt;">交互图，它们展示特定的对象彼如何此交互。由于它们处理特定案例而不是一般情况，因此它们在检验需求和检验设计时都能有所帮助。最流行的交互图是顺序图。</td></tr><tr style="height: 17.9pt;"><td valign="top" width="18%" style="padding: 0cm 5.4pt; width: 160.625px; height: 17.9pt;">在设计阶段</td><td valign="top" width="81%" style="padding: 0cm 5.4pt; width: 756.625px; height: 17.9pt;">类图，它们详述类与类之间的关系。</td></tr><tr style="height: 10.1pt;"><td valign="top" width="18%" style="padding: 0cm 5.4pt; width: 160.625px; height: 10.1pt;">观察对象的行为，这些行为因对象所处的状态而不同</td><td valign="top" width="81%" style="padding: 0cm 5.4pt; width: 756.625px; height: 10.1pt;">状态图，它们详述一个对象可能处于的不同状态以及这些状态之间的过渡。</td></tr><tr style="height: 4pt;"><td valign="top" width="18%" style="padding: 0cm 5.4pt; width: 160.625px; height: 4pt;">在布署阶段</td><td valign="top" width="81%" style="padding: 0cm 5.4pt; width: 756.625px; height: 4pt;">布署图，它们展示了不同的模块将被如何部署。我不会在此讨论它们。</td></tr></tbody></table><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">UML</span><span style="color: blue;">的定义包括UML语义和UML表示法两个部分：</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">UML语义　描述基于UML的精确元模型定义。元模型为UML的所有元素在语法和语义上提供了简单、一致、通用的定义性说明,使开发者能在语义上取得一致,消除了因人而异的最佳表达方法所造成的影响。此外UML还支持对元模型的扩展定义。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">UML表示法　定义UML符号的表示法,为开发者或开发工具使用这些图形符号和文本语法为系统建模提供了标准。这些图形符号和文字所表达的是应用级的模型,在语义上它是UML元模型的实例。<br />标准建模语言UML的重要内容可以由下列五类图(共9种图形)来定义:</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">&#183;第一类是<span style="color: blue;">用例图,从用户角度描述系统功能,并指出各功能的操作者。<br />&#183;第二类是静态图(Static diagram),包括类图、对象图和包图。其中类图描述系统中类的静态结构。不仅定义系统中的类,表示类之间的联系如关联、依赖、聚合等,也包括类的内部结构(类的属性和操作)。类图描述的是一种静态关系,在系统的整个生命周期都是有效的。对象图是类图的实例,几乎使用与类图完全相同的标识。他们的不同点在于对象图显示类的多个对象实例,而不是实际的类。一个对象图是类图的一个实例。由于对象存在生命周期,因此对象图只能在系统某一时间段存在。包由包或类组成,表示包与包之间的关系。包图用于描述系统的分层结构。<br />&#183;第三类是行为图(Behavior diagram),描述系统的动态模型和组成对象间的交互关系。其中状态图描述类的对象所有可能的状态以及事件发生时状态的转移条件。通常,状态图是对类图的补充。在实用上并不需要为所有的类画状态图,仅为那些有多个状态其行为受外界环境的影响并且发生改变的类画状态图。而活动图描述满足用例要求所要进行的活动以及活动间的约束关系,有利于识别并行活动。<br />&#183;第四类是交互图(Interactive diagram),描述对象间的交互关系。其中顺序图显示对象之间的动态合作关系,它强调对象之间消息发送的顺序,同时显示对象之间的交互;合作图描述对象间的协作关系,合作图跟顺序图相似,显示对象间的动态合作关系。除显示信息交换外,合作图还显示对象以及它们之间的关系。如果强调时间和顺序,则使用顺序图;如果强调上下级关系,则选择合作图。这两种图合称为交互图。<br />&#183;第五类是实现图( Implementation diagram )。其中构件图描述代码部件的物理结构及各部件之间的依赖关系。一个部件可能是一个资源代码部件、一个二进制部件或一个可执行部件。它包含逻辑类或实现类的有关信息。部件图有助于分析和理解部件之间的相互影响程度。<br />配置图定义系统中软硬件的物理体系结构。它可以显示实际的计算机和设备(用节点表示)以及它们之间的连接关系,也可显示连接的类型及部件之间的依赖性。在节点内部,放置可执行部件和对象以显示节点跟可执行软件单元的对应关系。</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/7d9f8fa3bf3e4ebbb9bd4dca716219c4.png" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">从应用的角度看,当采用面向对象技术设计系统时,首先是描述需求;其次根据需求建立系统的静态模型,以构造系统的结构;第三步是描述系统的行为。其中在第一步与第二步中所建立的模型都是静态的,包括用例图、类图(包含包)、对象图、组件图和配置图等五个图形,是标准建模语言UML的静态建模机制。其中第三步中所建立的模型或者可以执行,或者表示执行时的时序状态或交互关系。它包括状态图、活动图、顺序图和合作图等四个图形,是标准建模语言UML的动态建模机制。因此,标准建模语言UML的主要内容也可以归纳为静态建模机制和动态建模机制两大类。</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">静态视图：</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">类元</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/efedc2fd8506421b980a86304a603e67.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">关系的种类</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/4fd612f5e18344758381f4642b2ddf67.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">用例之间的关系</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/c3e3848eee1742a78166c7c4181e3014.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">状态的种类</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/654726e0c53a4c19aef42e82037f43a7.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">总结：</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">行为：事物随着时间进行的改变。状态图和活动图描述个别类型的行为。例如，用例，类，子系统，组件：顺序图描述一组类型的协作：我们使用协作图。许多类潜在的结构，来定义对象的协作，这些协作实现用例，或完成一个用例。协作是一组对象实现一个用例。状态图是对象的行为描述。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">售票系统设计（大家熟悉）：</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">用例视图</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/9a1427d48e6641d1adb5d28fa141aa93.png" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">顺序图</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/557edda05a224a4f995b33ffe3d84526.png" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">协作图</span><br />　　&nbsp;<img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/b738097a53d44de2b3e9ae2048ab69d3.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">状态机视图</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/f6c7e0e621ba44079d692b5ab69c6b92.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">活动视图</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/788d081089cf4782a3c4bcf051342ae9.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">物理视图</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">构件图</span><br />　　</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/f3d4f9ee94954610b84dfe5e842422a6.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">部署图（描述层）<br />　　</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/c6b411ba79a14922aaf27228780f982a.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">实例层部署图</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/dbda0d9b388546209fdd9ecda13ceaeb.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">模型管理视图</span></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/33220638ac254960a9b4571046b7569a.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><strong><span style="color: blue;">全面认识UML类图元素</span></strong>&nbsp;（<a target="_blank" href="http://blog.csdn.net/legendinfo/" style="color: #ca0000; text-decoration: none;">http://blog.csdn.net/legendinfo/</a>）</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">类（Class）</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">类（图A）是对象的蓝图，其中包含3个组成部分。第一个是Java中定义的类名。第二个是属性（attributes）。第三个是该类提供的方法。<br />属性和操作之前可附加一个可见性修饰符。加号（+）表示具有公共可见性。减号（-）表示私有可见性。#号表示受保护的可见性。省略这些修饰符表示具有package（包）级别的可见性。如果属性或操作具有下划线，表明它是静态的。在操作中，可同时列出它接受的参数，以及返回类型，如图A的&#8220;Java&#8221;区域所示。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">图A</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/7828c73331ea4151a73ab230eb403667.gif" style="border: none; max-width: 100%;" /><br />包（Package）</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">包（图B）是一种常规用途的组合机制。UML中的一个包直接对应于Java中的一个包。在Java中，一个包可能含有其他包、类或者同时含有这两者。进行建模时，你通常拥有逻辑性的包，它主要用于对你的模型进行组织。你还会拥有物理性的包，它直接转换成系统中的Java包。每个包的名称对这个包进行了惟一性的标识。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">图B</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/4c8f8d9aabdb4dca9a277f854fbc1f58.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">接口（Interface）</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">接口（图C）是一系列操作的集合，它指定了一个类所提供的服务。它直接对应于Java中的一个接口类型。接口既可用图C的那个图标来表示，也可由附加了&lt;&lt;interface&gt;&gt;的一个标准类来表示。通常，根据接口在类图上的样子，就能知道与其他类的关系。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">图C</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/b36f9eadfd584f1dba74caa5219538b8.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">关系</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">后面的例子将针对某个具体目的来独立地展示各种关系。虽然语法无误，但这些例子可进一步精炼，在它们的有效范围内包括更多的语义。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">依赖（Dependency）</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">实体之间一个&#8220;使用&#8221;关系暗示一个实体的规范发生变化后，可能影响依赖于它的其他实例（图D）。更具体地说，它可转换为对不在实例作用域内的一个类或对象的任何类型的引用。其中包括一个局部变量，对通过方法调用而获得的一个对象的引用（如下例所示），或者对一个类的静态方法的引用（同时不存在那个类的一个实例）。也可利用&#8220;依赖&#8221;来表示包和包之间的关系。由于包中含有类，所以你可根据那些包中的各个类之间的关系，表示出包和包的关系。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">图D</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/0f993949fff745999deb605d554590d2.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">关联（Association）</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">实体之间的一个结构化关系表明对象是相互连接的。箭头是可选的，它用于指定导航能力。如果没有箭头，暗示是一种双向的导航能力。在Java中，关联（图E）转换为一个实例作用域的变量，就像图E的&#8220;Java&#8221;区域所展示的代码那样。可为一个关联附加其他修饰符。多重性（Multiplicity）修饰符暗示着实例之间的关系。在示范代码中，Employee可以有0个或更多的TimeCard对象。但是，每个TimeCard只从属于单独一个Employee。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">图E</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/b770e146db704c8f85b53ef20d225598.gif" style="border: none; max-width: 100%;" /><br />聚合（Aggregation）</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">聚合（图F）是关联的一种形式，代表两个类之间的整体/局部关系。聚合暗示着整体在概念上处于比局部更高的一个级别，而关联暗示两个类在概念上位于相同的级别。聚合也转换成Java中的一个实例作用域变量。<br />关联和聚合的区别纯粹是概念上的，而且严格反映在语义上。聚合还暗示着实例图中不存在回路。换言之，只能是一种单向关系。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">图F</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/2825005037b84abe896b4f515186a34f.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">合成（Composition）</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">合成 （图G）是聚合的一种特殊形式，暗示&#8220;局部&#8221;在&#8220;整体&#8221;内部的生存期职责。合成也是非共享的。所以，虽然局部不一定要随整体的销毁而被销毁，但整体要么负责保持局部的存活状态，要么负责将其销毁。局部不可与其他整体共享。但是，整体可将所有权转交给另一个对象，后者随即将承担生存期职责。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">Employee和TimeCard的关系或许更适合表示成&#8220;合成&#8221;，而不是表示成&#8220;关联&#8221;。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">图G</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/f3bf19a91a604a15a360782dc984408b.gif" style="border: none; max-width: 100%;" /><br />泛化（Generalization）</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">泛化（图H）表示一个更泛化的元素和一个更具体的元素之间的关系。泛化是用于对继承进行建模的UML元素。在Java中，用extends关键字来直接表示这种关系。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">图H</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/a79bfb22d8fe42989072b84291a9316e.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">实现（Realization）</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">实例（图I）关系指定两个实体之间的一个合同。换言之，一个实体定义一个合同，而另一个实体保证履行该合同。对Java应用程序进行建模时，实现关系可直接用implements关键字来表示。</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">图I</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/843685e31db84719887e5ee2e1b1dfc1.gif" style="border: none; max-width: 100%;" /></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><strong><span style="color: blue;">术语大全</span></strong></div><div style="font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="color: blue;">access</span><span style="color: blue;">（访问）</span><br />访问是一种许可依赖关系，允许一个包引用另一个包中的元素。<br />见friend、import、visibility。<br />语义<br />一个包（客户）如果要引用另一个包（提供者）内的元素，那么它必须引入一个包，该包包括客户包到提供者包的《access》或《import》依赖关系上的元素。一个包可以隐含地获得对由包含该包的任何包所引入的包的访问权（即，嵌套包可以看到包含包可以看到的一切）。<br />包中的元素可以访问包内所有可见的元素。可见性规则可以总结如下：<br />* 一个包中定义的元素在同一个包中是可见的。<br />* 如果一个元素在一个包中是可见的，那么它对所有嵌套在这个包中的所有包都是可见的。<br />* 如果一个包访问或引入另一个包，那么在要被引入或访问的包中定义为公共可见性的元素对引入包都是可见的。<br />* 如果一个包是另一个包的孩子，那么所有在父包中定义为公共的或受保护的可见性的元素对子包是可见的。<br />* 访问或引入依赖关系是不能传递的，如果A能看到B，且B能看到C，这并不意味着A能看到C。<br />结论：除非一个包能够访问它的嵌套包且嵌套包的内容是公共可见的，否则这个包不能看到它自己的嵌套包的内部。<br />下面是有关可见性的更深一步的规则：<br />* 如果一个类元的内容，如它的属性和操作以及嵌套类，在类元中具有公共可见性，那么它们在包中是可见的。请注意一个子系统的未组织的内容是由上面提到的包规则指导的，但是任何子系统本身的属性或操作由这条规则指导。<br />* 如果一个类元的内容有公共的或受保护的可见性，那么它们对后代类元是可见的。<br />* 一个类元的所有内容对类元内的元素都是可见的，包括类元的方法或状态机中的元素。<br />一般情况下都会涉及到对等包中的元素。在这种情况下，一个元素能看到它自己包内的所有元素和被它所在包引入的包的具有公共可见性的所有元素。一个类可以看到其他类中的公共特征。一个类也可以看到它的祖先的受保护的特征。<br />表示法<br />访问依赖关系用一个从客户包指向提供者包的虚箭头表示。箭头用关键字《access》作为标号。<br />讨论<br />图为一个两个包间的对等层访问的例子。包P能够访问包Q，但是包Q不能访问包P。P包中的类K和L能看到包Q中的类M，但是它们看不到私有类N。除了具有公共可见性的类K之外，类M和N看不到包P中的任何类，因为包Q不能访问包P。要想一个类对对等包是可见的，这个类必须具有公共可见性，并且它的包必须被对等包访问或引入。<br /><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/ed7d47fe849e41308077b28f1abd4267.gif" style="border: none; max-width: 100%;" /><br />图对等访问<br /><img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/longronglin/96cccb5e8e70422a9cd22161d482e530.gif" style="border: none; max-width: 100%;" /><br />图访问规则<br />图为一个有关可见性和访问声明的更复杂的例子。元素名字前的符号代表了它的可见性：+代表公共的，#代表是受保护的（只对后代可见），-代表是私有的（对外界是不可见的）。<br />类A能看到C和E因为它们包含在包Y和X内。<br />类C和A能够看到D，因为包Y引入了包Z。类A嵌套在包Y中并且能够看到Y能看到的一切。<br />类A、C和E能看到B，因为它们嵌套在包X中，而X引入包含B的包V，但是，它们看不到F，因为F在它的包V中是有私有可见性。所以，类F在包V外是看不到的。<br />类E看不到D因为D在包Z中，而Z并没有被包X访问。<br />类C和E都看不到A。类A在包U中，U没有被任何包访问。<br />类B和F能够看到类D和E，D和E建立在包含包中。它们也能看到C，C在包Y中，而包Y被包含包访问。虽然F是私有的，但这并不影响它看到其他的类，而其他的类看不到F。<br />类B和F能够互相看到，因为它们在同一个包中。类F对外面的包中的类是私有的，但对它自己包中的类不是这样。</div><img src ="http://www.blogjava.net/wxb1988/aggbug/425452.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wxb1988/" target="_blank">wxb1988</a> 2015-06-02 16:00 <a href="http://www.blogjava.net/wxb1988/archive/2015/06/02/425452.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>