简体   繁体   English

UML用例图2个actor与1个用例相关联

[英]UML use case diagram 2 actors connected with 1 use case

What this example shows? 这个例子显示了什么?

图

Does it mean: 这是不是意味着:

a) Actor1 and Actor2 can use Use Case1 a)Actor1和Actor2可以使用Use Case1
b) both Actor1 and Actor2 are needed to start Use Case1 (for example two people need to turn keys for firing rocket?) b)需要使用Actor1和Actor2来启动Use Case1(例如,两个人需要转动钥匙才能发射火箭吗?)
c) Actor1 can start Use Case1 and Actor2 does something later c)Actor1可以启动Use Case1,Actor2可以稍后执行
d) Actor2 can start Use Case1 and Actor1 does something later d)Actor2可以启动Use Case1,Actor1可以稍后执行

Am I right that answer B is correct and: 我是对的,答案B是正确的,并且:

A would be: A将是:

图

C would be: C将是:

图

D would be: D将是:

图

Your response A ie Actor1 and Actor2 can use UseCase1 is the correct one. 您的响应A即Actor1和Actor2可以使用UseCase1是正确的。

Of course you can model that with your second diagram but in this case the model is a little bit different. 当然,您可以使用第二个图表对其进行建模,但在这种情况下,模型有点不同。 Actor1 and Actor2 can also use UseCase1 but this is due to the fact that they are specialization of Actor3 which is the only kind of actor having acces to the usecase1 Actor1和Actor2也可以使用UseCase1,但这是因为它们是Actor3的特化,这是唯一一种可以访问usecase1的actor

By UML definition, Actor is external entity to context of UseCase (for example modeled system, modul etc.) By definition, during usecase execution, system interracts with Actor. 通过UML定义,Actor是UseCase上下文的外部实体(例如建模系统,模块等)。根据定义,在用例执行期间,系统与Actor交互。 Association between UseCase and Actor does not define uses of usecase by Actor, but collaboration between Actor and system. UseCase和Actor之间的关联不定义Actor对usecase的使用,而是定义Actor和系统之间的协作。

Association navigability in usecase diagram does not define communication as well. 用例图中的关联导航性也不定义通信。

A would say, all answers are correct, because it is not possible to determine, which actor initialized usecase, when it interact with system or what actor does. 可以说,所有的答案都是正确的,因为当它与系统或演员做什么交互时,无法确定哪个演员初始化了用例。

You can provide more detailed description using definition of behaviors of system which implements (realize) functionality declared by usecases. 您可以使用系统行为的定义提供更详细的描述,该行为实现(实现)由usecases声明的功能。

Your question is conceptually rich and quite relevant since it addresses a key notion of the use case diagrams, which is the purpose of the actors. 您的问题在概念上很丰富且非常相关,因为它解决了用例图的关键概念,这是演员的目的。 To start with, understand that the sole purpose of an use case is to allow a given actor (the primary actor ) to reach a well determined goal (defined as a set of actions that yields an observable result ). 首先,要了解用例的唯一目的是允许给定的actor( 主要参与者 )达到一个明确的目标(定义为产生可观察结果的一组动作)。 If more than one actor is enabled to do that, either those actors are actually a single one or the use case delivers more than a single functionality, which is wrong (quoted from here ): 如果启用了多个actor,那么这些actor实际上只是一个,或者用例提供的功能不止一个,这是错误的(引自此处 ):

A use case is the specification of a set of actions performed by a system, which yields an observable result that is, typically, of value for one or more actors or other stakeholders of the system. 用例是由系统执行的一组动作的规范,其产生可观察的结果,该结果通常对于系统的一个或多个参与者或其他利益相关者是有价值的。

The goal the primary user achieves with a use case may deliver value to one or more actors , but keep in mind that only a single actor can be the primary one: if you have several actors associated to the same use case, one of them is primary and the remaining ones are necessarily secondary. 主用户通过用例实现的目标可以为一个或多个actor提供价值,但请记住,只有一个actor可以是主要的:如果有多个actor与同一个用例关联,其中一个是初级和其余的必然是次要的。 To quote the well renowned expert A. Cockburn : 引用知名专家A. Cockburn的话

The use case is associated with the goal of one particular actor, who is called primary actor for that use case. 该用例与一个特定参与者的目标相关联,该特定参与者被称为该用例的主要参与者 The use case describes the various sets of interactions that can occur between the various external agents, or actors, while the primary actor is in pursuit of that goal... The use case collects together all the scenarios related to that goal of that primary actor, including both those in which the goal is achieved, and those in which the goal must be abandoned. 该用例描述了各种外部代理或参与者之间可能发生的各种交互集合,而主要参与者正在追求该目标......用例将所有与该主要参与者的目标相关的场景收集在一起,包括实现目标的那些,以及必须放弃目标的那些。

As Cockburn makes crystal clear, a use case exists to fulfill some need of a single actor. 由于Cockburn清晰透明,因此存在一个用例来满足单个演员的某些需求。 Extra actors are supporting the system somehow to make it meet the primary actor's demand. 额外的演员正在以某种方式支持系统,以满足主要演员的需求。 To quote the excellent "UML @ Classroom" , written by Seidl, Scholz et. 引用由Seidl,Scholz等人撰写的优秀“UML @ Classroom” al, "If a use case is associated with two actors, this does not mean that either one or the other actor is involved in the execution of the use case: it means that both are necessary for its execution" . al, “如果一个用例与两个actor相关联,这并不意味着一个或另一个actor参与用例的执行:这意味着两者都是执行它们所必需的”

A brief discussion on use cases in a post from An Oracle blog about Unified Method also highlights the difference between primary and secondary actors: Oracle博客中关于统一方法的帖子中对用例的简要讨论也突出了主要和次要角色之间的区别:

Primary Actors : The Actor(s) using the system to achieve a goal. 主要演员 :使用系统实现目标的演员。 The Use Case documents the interactions between the system and the actors to achieve the goal of the primary actor. 用例记录了系统和参与者之间的交互,以实现主要参与者的目标。

Secondary Actors : Actors that the system needs assistance from to achieve the primary actor's goal. 次要演员 :系统需要协助以实现主要演员目标的演员。

... the Oracle Unified Method (OUM) concurs with the UML definition of Actors, along with Cockburn's refinement, but OUM also includes the following: ... Oracle统一方法(OUM)与Actors的UML定义以及Cockburn的改进一致,但OUM还包括以下内容:

Secondary actors may or may not have goals that they expect to be satisfied by the use case, the primary actor always has a goal, and the use case exists to satisfy the primary actor. 次要参与者可能有也可能没有他们希望用例满足的目标,主要参与者总是有目标,并且存在满足主要参与者的用例。

The same idea is supported by Martin Fowler in his classic UML Distilled : Martin Fowler在他的经典UML Distilled中支持同样的想法:

Each use case has a primary actor, which calls on the system to deliver a service. 每个用例都有一个主要角色,它调用系统来提供服务。 The primary actor is the actor with the goal the use case is trying to satisfy and is usually, but not always, the initiator of the use case. 主要角色是具有用例试图满足的目标的角色,并且通常(但不总是)是用例的发起者。 There may be other actors as well with which the system communicates while carrying out the use case. 在执行用例时,系统可能还有其他参与者。 These are known as secondary actors. 这些被称为次要演员。

So, all in all, there is one - and only one - primary actor for each use case. 总而言之,每个用例都有一个 - 也是唯一一个 - 主要角色。 Now, you have in your first diagram two actors and only one (the primary actor) is entitled to use the system in order to achieve a goal (the other actor assists the system to achieve the primary actor's goal). 现在,您在第一个图中有两个演员,只有一个(主演员)有权使用系统来实现目标(另一个演员协助系统实现主要演员的目标)。 This description fits the alternatives (c) and (d) in your list, but remember: it is not mandatory that the primary user starts the use case (it could be initiated by an internal or temporal event as well). 此描述符合列表中的备选方案(c)和(d),但请记住:主要用户不必强制启动用例(也可以由内部或时间事件启动)。

You interpreted correctly how item (a) has to be depicted since both Actor 1 and 2 are specializations of Actor 3, the one associated to the use case, which makes correct to state that "Actor1 and Actor2 can use Use Case1". 您正确解释了如何描述项(a),因为Actor 1和2都是Actor 3的特化,与用例相关联,这使得“Actor1和Actor2可以使用Use Case1”的说法正确。 But I am afraid you missed the point in the item (b) however. 但是,我担心你错过了(b)项中的要点。 Indeed, item (b) does not depicts the first diagram as you supposed because you stated that "Actor1 and Actor2 are needed to start Use Case1". 实际上,项目(b)没有描述你想要的第一个图,因为你说“ 需要使用Actor1和Actor2 来启动 Use Case1”。 Again, use cases are initiated by internal (also "state"), temporal or external events (you can read more about that here ); 同样,用例由内部(也称为“状态”),时间或外部事件启动(您可以在此处阅读更多内容); so, since there is a single primary actor for a given use case, by no means it needs two actors to be started. 因此,由于给定用例只有一个主要角色,因此决不需要启动两个角色。 If you need an actor do something in order to allow another actor start an use case, this would be a pre-condition for that use case. 如果你需要一个演员做某事以便允许另一个演员开始一个用例,这将是该用例的先决条件。 With this regard, note that you can always use the notion of multiplicity to specify that two or more instances of an actor are required to execute the use case ( here ): 在这方面,请注意您始终可以使用多重性的概念来指定执行用例( 此处 )需要两个或更多个actor实例:

If a multiplicity greater than 1 is specified for the actor's association end, this means that more than one instance of an actor is involved in the execution of the use case. 如果为actor的关联结束指定了大于1的多重性,则这意味着在执行用例时涉及多个actor的实例。

For clarity, consider the following reasoning. 为清楚起见,请考虑以下推理。 An actor is a role played by one or more users within the context of an executing use case. 参与者是一个或多个用户在执行用例的上下文中扮演的角色。 So, if Mary and John are system's users entitled to start an use case named, say, Sell an Item , both are playing the same role at that very moment as a single actor named, say, Seller . 因此,如果Mary和John是系统用户有权开始一个名为“ 销售项目”的用例,那么两者在当时扮演的角色都是一个名为卖家单个角色。 It doesn't matter that, in reality, they are a sales clerk and a sales manager: in the use case diagram, both act as a "the" Seller (actor). 实际上,他们是销售员和销售经理并不重要:在用例图中,两者都充当“ 卖方” (演员)。

In the picture below, you can see three use case diagrams, where we can further extend the argument. 在下图中,您可以看到三个用例图,我们可以在其中进一步扩展参数。

三种不同的用例配置

UC-1 shows an use case in which two different actors, Sales Clerk and Sales Manager , are required to execute the use case Sell an Item ; UC-1显示了一个用例,其中需要两个不同的参与者, 销售文员销售经理来执行用例销售物品 ; ie, in the UC-1's description, both are needed to run it. 也就是说,在UC-1的描述中,两者都需要运行它。 That could indicate, for example, that every sale performed by a clerk has to be approved by a sales manager. 这可能表明,例如,职员进行的每次销售都必须得到销售经理的批准。 In this case, Sales Clerk is a primary actor because it starts the use case and get some benefit from it (perform a sale) and Sales Manager is a secondary actor (it is involved in the execution). 在这种情况下, 销售文员是主要参与者,因为它启动用例并从中获得一些好处(执行销售),而销售经理是次要参与者(它参与执行)。

In UC-2 , both the manager ( Sales Manager ) and the seller ( Sales Clerk ) can sell an item (ie, start the Sell an Item use case). UC-2中 ,经理( 销售经理 )和销售人员销售员 )可以销售物品(即,开始销售物品用例)。 Given that both perform the same role as a seller, this is likely to be modelled as an inheritance as depicted - Sales Clerk "IS A" Seller and the same goes for Sales Manager . 鉴于两者都扮演与卖家相同的角色,这很可能被建模为所描述的继承 - 销售员 “是一个” 卖方销售经理也是如此 As pointed out above, both actors are acting as "the" seller ( Seller ). 如上所述,两个参与者都充当“卖方”( 卖方 )。

UC-3 depicts exactly the same situation seen in UC-1 , with a minor difference though: the arrows indicate clearly who is the primary and the secondary actors ( Sales Clerk and Sales Manager , respectively). UC-3描述了在UC-1中看到的完全相同的情况,虽然略有不同:箭头清楚地表明谁是主要和次要角色(分别是销售员销售经理 )。 As far as I am aware, those arrows are not standardized (quoting UML @ Classroom : " Graphically, there is no differentiation between primary and secondary actors, between active and passive actors... "). 据我所知,这些箭头没有标准化(引用UML @ Classroom :“从图形上看,主要和次要角色之间,主动和被动角色之间没有区别...... ”)。

To finalize the argument, consider the following use case diagram: 要完成参数,请考虑以下用例图: 两个参与者参与用例执行。只有一个启动它

Could you say that both actors, Seller and Credit Card Company are entitled to start this use case? 您是否可以说演员, 卖家信用卡公司都有权启动此用例? Of course not, this would be plainly wrong, as we know beforehand that credit card companies do not sell items in stores, but support sales through their computerized systems. 当然不是,这显然是错误的,正如我们事先所知,信用卡公司不会在商店销售商品,而是通过计算机系统支持销售。 In the same fashion, it would be a mistake to state that both Sales Clerk and Sales Manager might start the Sell an Item use case in the UC-1 diagram above. 以同样的方式,说明销售员销售经理可能在上面的UC-1图中启动销售物品用例是错误的。

Take a look here to a textbook on that. 看看本教科书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM