📄 200604240937105.html
字号:
<html>
<head><title>用例</title></head>
<center><h1>用例</h1></center>
<div><FONT face=Verdana>
<P align=right><FONT face=黑体><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="2006330181252588.jpg" tppabs="http://www.itisedu.com/manage/Upload/image/2006330181252588.jpg" border=0></FONT></FONT></FONT></P>
<P> <a href="javascript:if(confirm('http://www.itisedu.com/phrase/200603042249305.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/200603042249305.html'" tppabs="http://www.itisedu.com/phrase/200603042249305.html" target="_new">Use Case</a>(<a href="200604240937105.html" tppabs="http://www.itisedu.com/phrase/200604240937105.html" target="_new">用例</a>)是一个<a href="200602271429302.html" tppabs="http://www.itisedu.com/phrase/200602271429302.html" target="_new">UML</a>中非常重要的概念,在使用UML的整个<a href="200603282233345.html" tppabs="http://www.itisedu.com/phrase/200603282233345.html" target="_new">软件开发</a>过程中,Use Case处于一个中心地位。 <BR> <BR> 那么,到底什么是Use Case呢?在UML的文档中,Use Case的定义是:在不展现一个系统或<a href="200604161433025.html" tppabs="http://www.itisedu.com/phrase/200604161433025.html" target="_new">子系统</a>内部结构的情况下,对系统或子系统的某个连贯的功能单元的定义和描述。有点拗口,对吧?其实Use Case就是对系统功能的描述而已,不过一个Use Case描述的是整个系统功能的一部分,这一部分一定要是在逻辑上相对完整的功能流程。(唔?Use Case也没什么特别的嘛!怎么这玩意儿会在开发中处于一个中心地位呢?)在使用UML的开发过程中,<a href="200603101518295.html" tppabs="http://www.itisedu.com/phrase/200603101518295.html" target="_new">需求</a>是用Use Case来表达的,界面是在Use Case的辅助下设计的,很多<a href="200603090857555.html" tppabs="http://www.itisedu.com/phrase/200603090857555.html" target="_new">类</a>是根据Use Case来发现的,测试实例是根据Use Case来生成的,包括整个开发的管理和任务分配,也是依据Use Case来组织的。啊,Use Case,简直太重要了!好了,Use Case就吹到这儿,具体的使用还要在实践中去体会,“运用之妙,存乎一心” 也! <BR> <BR> 对于每个Actor来说,他都要使用系统的某项功能,所以我们识别和分析Use Case是,要 对于每个Actor来逐个进行。对于ToDo User,我们可以轻易的识别出两个Use Case:Add Task 和 Remove Task。ToDo User主动使用这两个Use Case所描述的系统功能,所以在我们的Use Case图上,ToDo User和这两个Use Case的关系是用从ToDo User发出的箭来表示的。对于FileSystem,我们识别出的也是同样的两个Use Case,不过这次箭头从Use Case指向FileSystem,表示FileSystem是被动的。 </P>
<P> Use Case可以用很多方式来描述,我们可以用自然语言(英语,汉语,随您的便),可以用形式化语言(哇!太酷了吧!),也可以用各种图示。在UML中,通常用两种图来描述Use Case,它们就是<a href="200604161949135.html" tppabs="http://www.itisedu.com/phrase/200604161949135.html" target="_new">顺序图</a>(<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604241342195.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/200604241342195.html'" tppabs="http://www.itisedu.com/phrase/200604241342195.html" target="_new">Sequence Diagram</a>)和<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604161756595.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/200604161756595.html'" tppabs="http://www.itisedu.com/phrase/200604161756595.html" target="_new">协作图</a>(<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604241345335.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/200604241345335.html'" tppabs="http://www.itisedu.com/phrase/200604241345335.html" target="_new">Collaboration Diagram</a>) </P>
<P> Use Case 由以下元素组成:<BR> 名称<BR> 简单描述<BR> 事件流<BR> 关系<BR> <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="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><BR> Use Case 图<BR> 特殊需求<BR> 前条件<BR> 后条件</P>
<P><STRONG>一、谈谈对use case有关术语翻译的看法。</STRONG></P>
<P> 笔者认为“用例”是目前较好的译法,这个词可能来源于大家熟知的“<a href="200603291707535.html" tppabs="http://www.itisedu.com/phrase/200603291707535.html" target="_new">测试用例</a>”。有人认为把use case翻译成“用例”是错误的,理由是:“‘例’是被列举出来以说明某种情况的个别事物,use case是对一项系统功能使用情况的普遍适应的描述,而不是对个别actor或者在个别条件下使用这项功能才适应,它也不是通过举例的方式来描述的”,所以不能叫作“用例”。此种说法不尽全面,而且有些牵强(先不管它正确与否),其实use case到底是个别的,还是群体的(普遍适应),取决于我们的视点。虽然对于单个的scenario来说,use case是多个情节的叠加,是一个整体的复合概念,但是我们知道,一个系统的功能必定是可数的、有限的,而每一个功能都可以表示为一个use case,所以在观察系统提供的所有功能需求的集合这个层面上,use case又是一个一个可数的个体(“椭圆”),每一个都代表了不同的用户目标,适用于个别的actor和个别特定的前置条件。同一个事物既是个体的又是整体的,这种现象并不足怪,例如在UML<a href="200603090845215.html" tppabs="http://www.itisedu.com/phrase/200603090845215.html" target="_new">对象</a>-类-类元关系中,通常对象是类的实例,而类又是类元的实例,对类元来说,类、接口、子系统、use case等等就是一个个个体的概念,类既是其对象实例的集合又是其类元集合的个别元素。可见,把use case的“case”译成“例”并没有错。</P>
<P> 有的地方把use case翻译成“用况”,即“使用的情况”之意,意思的确不错(use case的另一种说法是“使用的方式”)!可我总感觉这个词比较突兀、拗口,类似的还有“用案”,把scenario叫作“案况”,大概这些词读起来不太符合大家的习惯(类似地,既然可以叫“用况”,为什么不能叫“用情”呢?),所以现在“用例”的叫法还是越来越多了。</P>
<P> 其实“用例”这个译法还有个附带的好处,通过它我们很容易把原本就存在紧密联系的use case和<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604240904345.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/200604240904345.html'" tppabs="http://www.itisedu.com/phrase/200604240904345.html" target="_new">test case</a>(test case来自于对scenario的分析,而scenario是用例的一次执行)从中文名称上也方便地统一起来。不过,这里我们需要做一个小小的改进。中文的“测试用例”到底是指test case(带定语的名词词组)呢,还是指对用例进行测试(testing the use cases,动宾词组)呢?显然这两者不易分辨,而且若“用例”和“测试用例”两个词同时出现在一啰个句子或一段话中,常常会让人感觉嗦和便扭。为了消除歧义,干脆以后把test case都叫做“测例”,这样不但比以前的叫法更加简洁明了,而且无论字面上还是语义上都很贴切。当然,用例和测例是不同层面的“例”。</P>
<P> 现在市面上Actor也有多种译法,常见的包括“参与者、执行者、主角”等等。“参与者、执行者”的问题主要是不准确。首先,“参与者” 通常让大家马上想到的词是participant,而且请注意,一个用例的真正参与者决不是只有外部的Actor,它们必然还包括系统本身及其内部的各种元素。“执行者”的问题与此类似:一个用例的真正执行者应该是系统本身!因此严格地讲这样译是错误的,兴许叫作“外部参与者”、“外部执行者”才更为恰当。“主角”的译法同样存在着矛盾。如果把Actor叫作“主角”,那么Primary Actor就应该叫作“主主角”了。看来Actor的译法中是不能含有“主”的,那么就剩下“角”了,而UML已经有了一个专门术语role(角色),我们又不能把Actor直接叫作“角色”。<BR>目前看来,把Actor意译成“使用者”是比较妥当的。在大多数情况下Actor的的确确就是用户(确切地说是系统用户所扮演的一种角色),所以我们可以用“使用者”这个词从字面上与“用户”(user)进行区分,但同时又保持两者语义上的联系。我们还可以把为系统服务的Supporting/Secondary Actor(见下文)叫做“被使用者”(为了简化可以省略“被”字)或“辅使用者”。除了指系统的用户之外,“使用者”还有另一层含义,即Actor是use case的使用者(或被使用者),这种关系在UML<a href="200603071221195.html" tppabs="http://www.itisedu.com/phrase/200603071221195.html" target="_new">用例图</a>上应该可视化地表示为它们之间的连线(关联)。这样解释不但说的通,而且更便于不熟悉<a href="200604232134205.html" tppabs="http://www.itisedu.com/phrase/200604232134205.html" target="_new">软件</a>技术的业务人员理解。<BR>当然,我们也不排除将来会找到“use case”、“actor”等术语更好的译法。</P>
<P><STRONG>二、USE CASE的来历</STRONG></P>
<P> Ivar Jacobson在1967年定义爱立信AXE系统的够架时开始书写使用场境usage scenarios。</P>
<P> 二十世纪八十年代中期Jacobson花了很多精力来思考过去十多年的工作方法。他造了一个术语anvendningsfall,大意是“使用情况”(situation of usage)或用况(usage case)。但当用英文出版的时候,他发现“useage case”在英语里说不通,所以写作用例“use case”</P>
<P><STRONG>三、创建USE CASE的原则</STRONG></P>
<P> 用例是短文<BR> 用例可以是一个场景,包括动作和互交。<BR> 用例可以是一组场景,描述不同场景下的行为。这种书写格式可以在任何时候描述有变体的行为,例如黑盒需求,业务流程,系统设计说明。<BR> 用例里不要有系统设计<BR> 用例里不要有界面设计<BR> 用例里不要有特性列表<BR> 用例里不要有测试<BR> 用例应该描述行为需求<BR> 用例的主场景不要超过九步。可以在适当的层次上得到子目标和移除设计说明。<BR> 用例的最大价值不在于主场景,而是在于备选行为。主场景可能只占用例长度的四分之一到十分之一。</P>
<P><STRONG>四、Use Case 事件流</STRONG></P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -