📄 200604161949135.html
字号:
<html>
<head><title>顺序图</title></head>
<center><h1>顺序图</h1></center>
<div><P align=right><FONT face=Verdana><FONT color=#f70938><FONT face=黑体><a href="200604112229525.html" tppabs="http://www.itisedu.com/phrase/200604112229525.html" target="_new">中科永联</a>高级技术培训中心(</FONT><FONT face=黑体>www.itisedu.com</FONT><FONT face=黑体>)<IMG src="2006416195350529.jpg" tppabs="http://www.itisedu.com/manage/Upload/image/2006416195350529.jpg" border=0></FONT></FONT></FONT></P>
<P><FONT face=Verdana> <a href="200604161949135.html" tppabs="http://www.itisedu.com/phrase/200604161949135.html" target="_new">顺序图</a>是将交互关系表示为一个二维图。纵向是时间轴,时间沿竖线向下延伸。横向轴代表了在协作中各独立<a href="200603090845215.html" tppabs="http://www.itisedu.com/phrase/200603090845215.html" target="_new">对象</a>的<a href="200603090857555.html" tppabs="http://www.itisedu.com/phrase/200603090857555.html" target="_new">类</a>元角色。类元角色用生命线表示。当对象存在时,角色用一条虚线表示,当对象的过程处于激活状态时,生命线是一个双道线。</FONT></P>
<P><FONT face=Verdana> <a href="200603090938465.html" tppabs="http://www.itisedu.com/phrase/200603090938465.html" target="_new">消息</a>用从一个对象的生命线到另一个对象生命线的箭头表示。箭头以时间顺序在图中从上到下排列。</FONT></P>
<P><FONT face=Verdana> 和<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604241345455.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200604241345455.html'" tppabs="http://www.itisedu.com/phrase/200604241345455.html" target="_new">合作图</a>、<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200603101530375.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200603101530375.html'" tppabs="http://www.itisedu.com/phrase/200603101530375.html" target="_new">活动图</a>一样,<a href="200602271429302.html" tppabs="http://www.itisedu.com/phrase/200602271429302.html" target="_new">UML</a>顺序图( Rumbaugh、Jacobson、和booch, 1999)是一种动态建模方法。 UML顺序图一般用于:确认和丰富一个使用情境的逻辑。一个使用情境就是系统潜在的使用方式的描述,也就是它的名称所要描述的。一个使用情境的逻辑可能是一个<a href="200604240937105.html" tppabs="http://www.itisedu.com/phrase/200604240937105.html" target="_new">用例</a>的一部分,或是一条备选线路;一个贯穿单个用例的完整流程,例如动作基本过程的逻辑描述,或是动作的基本过程的一部分再加上一个或多个的备用情境的逻辑描述。或是包含在几个用例中的流程,例如一个学生注册入学之后,立即就要在三个班级注册。</P>
<P> 研究你的设计,因为它们为你提供了一种方式,你可以使用这种方式来可视化的调用类定义的操作。检测<a href="200603101726185.html" tppabs="http://www.itisedu.com/phrase/200603101726185.html" target="_new">面向对象</a>的设计中的瓶颈。 通过观察什么消息被发送给一个对象,以及通过概略的观察运行被调用的方法需要花费多长时间,你很快就能了解那里的设计需要变化,以达到在系统内部平衡负荷的目的。 实际上某些CASE工具甚至能够让你模拟<a href="200604232134205.html" tppabs="http://www.itisedu.com/phrase/200604232134205.html" target="_new">软件</a>这些特征。</P>
<P>使你能够感觉到你的应用<a href="200604232224305.html" tppabs="http://www.itisedu.com/phrase/200604232224305.html" target="_new">程序</a>的那个类将会变得复杂的,这是个信号,意味着你需要为那些类画<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604161451045.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200604161451045.html'" tppabs="http://www.itisedu.com/phrase/200604161451045.html" target="_new">状态图</a>了。</P>
<P><STRONG>通用准则</STRONG></P>
<P>尽力保持消息的顺序是从左到右排列的。</P>
<P>一个顺序图的消息流开始于左上方,消息乙的位置比消息甲低,这意味着消息乙的顺序比消息乙要迟。因为西方的阅读习惯是从左到右,你应该尽量按照和描述消息流一样的方式,从左至右排列分类器(角色、类、对象,和用例)。 在图1中你可以看到分类器已经按照这种方式排列好了,如果Seminar对象在controller的左边,那排列方式就不是标准的了。 注意有时候消息流从左到右的排列是不可能的,例如一对对象彼此调用操作的情形。</P>
<P><STRONG>将分类器<a href="200604161254415.html" tppabs="http://www.itisedu.com/phrase/200604161254415.html" target="_new">分层</a></STRONG></P>
<P>分层是一个通用的<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200603050045535.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200603050045535.html'" tppabs="http://www.itisedu.com/phrase/200603050045535.html" target="_new">面向对象设计</a>的方法,系统通常来说,总是组织成user interface、process/controller、business、persistence、和system层( Ambler 2001)。 当系统是以这种方式设计的时候,通常会加强同属于一层的分类器合作,而降低不同层的分类器的耦合度。 因此按类似的方式对你的顺序图进行分层是有意义的。 就这个使用情境的例子来说,一种分层的方法就是先注明人类角色,然后是表示情境的逻辑的controller类,然后是user interface类,接着是business类,最后是相关的技术类,它封装了对<a href="200602271218062.html" tppabs="http://www.itisedu.com/phrase/200602271218062.html" target="_new">数据库</a>和系统资源的访问。 以这种方式对你的顺序图分层,会使得顺序图更容易阅读,也更容易发现分层的逻辑问题。 图1就采取这种方法。</P>
<P>图⒈一次学生的注册。</P>
<P align=center><IMG src="2006416195143729.gif" tppabs="http://www.itisedu.com/manage/Upload/image/2006416195143729.gif" border=0></P>
<P><BR>用和你的<a href="200603071221195.html" tppabs="http://www.itisedu.com/phrase/200603071221195.html" target="_new">用例图</a>一致的名称命名角色。</P>
<P>当你在对一个使用情境建模时,你的顺序图一般会涉及一个或多个角色。 为了保持一致性,显示在顺序图中的角色的名称应该和用例图上的相同。</P>
<P>用和你的<a href="200603071659325.html" tppabs="http://www.itisedu.com/phrase/200603071659325.html" target="_new">类图</a>一致的名称命名类。</P>
<P>顺序图中的类和类图中的类是相同的,因此它们应该有相同的名称。</P>
<P>一个角色的名称可以和类的名称相同。</P>
<P>在图1你可以看到一个命名为学生的角色和一个命名为学生的类。 这样做是合理的,因为这两个分类器表示两个不同的概念,角色表示在现实中的学生,而类则表示你正在构建的商业应用程序中的学生。</P>
<P>包含一个逻辑的叙述性描述。</P>
<P>图1可以很难理解--特别是对于不熟悉阅读顺序图人来说--因为它是很接近于实际的源程序。 在你模型中包含一个业务逻辑的描述是很常见的,特别当该顺序图描述一个使用情境时,就像在在图⒉的左边看到的,这可以增加图的可理解性,并且Rosenberg和Scott(1999)指出,这也为跟踪用例和顺序图间的信息提供了重要的信息。</P>
<P>图⒉在线定单付款。</P>
<P align=center><IMG src="2006416195153133.gif" tppabs="http://www.itisedu.com/manage/Upload/image/2006416195153133.gif" border=0></P>
<P><BR>在图的最左边放置人和组织角色。</P>
<P>对业务应用软件来说,在大多数的中,主要的角色是一个人或一个组织。这些角色经常是该情境的发起人,同时也是顺序图的阅读焦点,因此它们应该放在模型的"可看见的开始之处"。</P>
<P>在图的最右边放置反应系统角色。</P>
<P>反应系统角色是那些你与之交互的系统,应该放在图的最右边。因为在许多的业务应用软件中,这些角色经常被当做" backend entities ",也就是那些你的系统通过存取技术交互的系统,例如C APIs、<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604031336425.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200604031336425.html'" tppabs="http://www.itisedu.com/phrase/200604031336425.html" target="_new">CORBA</a> IDL、消息队列、或web service。 换句话说,把后端的系统放在图最后的位置。</P>
<P>在图的最左边放置系统角色。</P>
<P>先导系统角色是那些与你的系统交互的系统,根据力争从左到右排列消息和分类器层的原则,应该放在图的最左边。</P>
<P><STRONG>避免建模对象Destruction</STRONG></P>
<P>虽然内存管理是很重要的的问题,特别是对象在适当的时候的销毁,许多建模者不愿意在顺序图上建模对象的销毁操作,而是在activation条(就是表示对象生命周期的那个竖条)的底部使用一个"X"符号,或使用一个带<>版型的消息。 比较图1和图2,注意图1中引入了对象的销毁,没带来明显的好处,却弄乱了图的布局。而图2则没有注明对象销毁。 记住遵循<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200603091620485.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200603091620485.html'" tppabs="http://www.itisedu.com/phrase/200603091620485.html" target="_new">敏捷建模</a>( <a href="javascript:if(confirm('http://www.itisedu.com/phrase/200603091620485.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200603091620485.html'" tppabs="http://www.itisedu.com/phrase/200603091620485.html" target="_new">AM</a>)的实践简单的描述模型。</P>
<P>这项指南的意义在于两个理由∶ 首先,很多种语言都拥有称作垃圾收集的技术,实现自动的内存管理,例如Java和Smalltalk。 其次,在那些你需要明确的管理内存的语言中,例如C++,你的程序员一般地都能够了解该怎么做,并不需要模型中的这些附加信息。</P>
<P>注意在实时系统中,内存管理通常是一个关键性问题,你可能需要建模对象的销毁操作。</P>
<P><STRONG>分类器的原则</STRONG></P>
<P>注意∶分类器命名规则的在别处描述。 其中,类和接口的命名规则在UML类图的风格指南中描述,用例的命名规则在UML用例图的风格指南中描述,而<a href="200603302222545.html" tppabs="http://www.itisedu.com/phrase/200603302222545.html" target="_new">组件</a>的命名规则在UML<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604161810285.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200604161810285.html'" tppabs="http://www.itisedu.com/phrase/200604161810285.html" target="_new">组件图</a>的风格指南中描述。</P>
<P>当你在消息上引用对象时要命名他们。</P>
<P>顺序图上的对象应使用标准的UML格式" name: ClassName "来标记,其中" name "可选的(拥有一个名称的对象称作已命名的对象,而那些没有名称的对象则被称作匿名对象)。在图1中,Student的实例以theStudent来命名,因为它是一条消息已引用返回值,然而SecurityLogon类的实例则不需要名称,因为图的其它地方并没有应用它,因此它可以使匿名的。</P>
<P>当存在部分相同的<a href="200603051002565.html" tppabs="http://www.itisedu.com/phrase/200603051002565.html" target="_new">类型</a>时需要命名对象。</P>
<P>当一个顺序图包含几个同样类型的对象时,例如图3存在两个Account类的实例,你应该为该类型的所有对象命名,以避免图的意义含糊不清。</P>
<P>图⒊在账户间转帐。</P>
<P align=center><IMG src="200641619523327.gif" tppabs="http://www.itisedu.com/manage/Upload/image/200641619523327.gif" border=0></P>
<P><BR>一致地应用文本版型。</P>
<P>表1总结了一些通用版型,你可以在顺序图的分类器上应用它们。 不要花过多的时间来争论应该使用哪个版型,例如<>和<>都是不错的版型,只要随便选择一个并保证一致性就好了。</P>
<P>表⒈通用的版型.</P>
<P>版型 用法</P>
<P><> 在设计期间表示微软的Active Server Page。</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -