美文网首页
SAD Chapter 6: Behavioral Modeli

SAD Chapter 6: Behavioral Modeli

作者: 青蛙水手 | 来源:发表于2021-04-06 04:00 被阅读0次

    SAD Chapter 6: Behavioral Modeling –UML ObjectInteraction

    Interaction Diagrams 互动图(交互图)

    •An Interaction diagram shows step-by-step, one of theflows through a use case: what objects are needed for the flow, what messagesthe objects send to each other, what actor initiates the flow, and what orderthe messages are sent.

    一个互动图(交互图)一步步显示了一个用例中的流程之一:该流程需要哪些对象,这些对象彼此之间发送哪些消息,哪个参与者发起该流程以及消息的发送顺序。

    •Sequence diagrams can show a focus of control;Communication diagrams can show a data flow.

    循序图(时序图)可以显示执行事件;通讯图可以显示数据流。

    •While the flow of events focuses on what the systemneeds to do, Sequence and Communication diagrams help to define how the systemwill do it.

    事件流着重于系统需要做什么,而循序图(时序图)和通讯图则有助于定义系统的工作方式。

    •The steps involved in creating a Sequenceor Communication diagram are:

    创建循序图(序列图)或通讯图的步骤包括:

    • Find the objects.   找到对象

    • Find the actor.      找到参与者

    Add messages to the diagram. 向图中添加消息

    Categories of Objects 对象(物件)的种类

    Entity objects These are objects that hold information. They may eventually map to some of the tables and fields in the database.

    实体对象(物件):保存信息的对象。它们最终可能会映射到数据库中的某些表和字段。

    Boundary objects These are objects that lie on the boundary between the system and the outside world. In other words, these are the forms and windows of the application and theinterfaces to other applications.

    边界对象(物件):这些对象位于系统和外界之间的边界上。换句话说,这些是应用程序的形式和窗口以及与其他应用程序的接口。

    Control objects These are optional objects that control the flow through the use case. They don't carry out any business functionality in and of themselves.

    控制对象(物件):这些是可选对象(物件),用于控制通过用例的流程。他们本身并不执行任何业务功能。

    Sequence Diagrams 循序图(时序图)

    Sequence diagramsare Interaction diagrams that are ordered by time; we read thediagram from the top to the bottom. 循序图(时序图)是按时间排序的交互图;我们从上至下阅读该图。

    •Each object has alifeline, drawn as avertical dashed line below the object. Each message represents one object making a function call of another.

    每个对象(物件)都有一条生命线,在对象下方以垂直虚线绘制。每个消息代表一个对象(物件),该对象(物件)对另一个对象(物件)进行函数调用。

    Communication Diagrams 通讯图

    •While Sequence diagrams are ordered by time,Communication diagrams focus more on the relationships between the objects. 虽然时序图按时间排序,但通讯图更多地关注对象之间的关系。

    •On a Sequence or Communication diagram,each object may be mapped to a class.

    在循序图(时序图)或通讯图上,每个对象(物件)都可以映射到一个类。

    Setting Object Persistence 设置对象(物件)持久性

    PersistentApersistent object is one that will be saved to a database or to some other formof persistent storage.    持久       持久对象是指被保存到数据库或某种其他形式的持久存储中的对象。

    StaticAstatic object is one that stays in memory until the program is terminated.

    静态     静态对象是在程序终止之前一直保留在内存中的对象。

    TransientAtransient object is one that stays in memory only for a short time.

    瞬态     瞬态对象是仅在内存中保留很短时间的对象。

    Mapping a Message to an Operation     将消息映射到方法

    •Before you generate code, each message on yourSequence and Communication diagrams should be mapped to an operation of aclass.

    生成代码之前,应将序循序图(时序图)与 通讯图上的每个消息映射到一个类的方法。

    Simple   简单

    •This is the default value for messages. This option specifies that the message runs in a single thread of control.  这是消息的默认值。 此选项指定消息在单个控制线程中运行。

    Synchronous        同步

    •Use this option when the client sends themessage and waits until the supplier has acted upon the message.

    当客户端发送消息并等待供应商(supplier)对消息采取行动之前,请使用此选项。

    Balking

    •With this option, the client sends the message to thesupplier. If the supplier is not immediately ready to accept the message, the client abandons the message.

    使用此选项,客户端将消息发送给供应商。 如果供应商尚未立即准备好接受该消息,则客户端将放弃该消息。

    Timeout 超时

    •Using this option, the client sends the message to thesupplier and waits a specified amount of time. If the supplier isn't ready to receive the message in that time, the client abandons the message.

    客户端使用此选项将消息发送给供应商,并等待指定的时间。 如果供应商当时还没有准备好接收消息,则客户端放弃该消息。

    Asynchronous 异步

    •With this option, the client sends the message to the supplier. The client then continues processing, without waiting to see if the message was received or not.

    使用此选项,客户端将消息发送给供应商。 然后,客户端继续处理,而无需等待查看是否已收到消息。

    Procedure Call     程序调用

    •With this option, the client sends the message to the supplier. The client then must wait until the entire nested sequence of messages is processed before continuing.

    使用此选项,客户端将消息发送给供应商。 然后,客户端必须等待,直到处理完整个嵌套的消息序列为止,然后才能继续。

    Return   返回

    •This option indicates the return from a procedure call.       此选项指示从过程调用返回。

    Setting Message Frequency     设置消息频率

    •Message frequency lets you mark a message to be sent at regular intervals.

    消息频率使您可以标记要定期发送的消息。

    For example, you have a message that should run once every 30 seconds. You can set that message to be periodic.         例如,您有一条消息,应该每30秒运行一次。您可以将该消息设置为定时的。

    End of a Lifeline   生命线的结束

    •The destruction marker is used to indicate the end of a lifeline. It appears as an "X" on the lifeline itself, and thelifeline will not extend beyond it.

    毁灭标记用于指示生命线的结束。 它在生命线本身上显示为“ X”,并且生命线不会超出其范围。

    Working with Scripts  使用脚本

    •Scripts are usually used to add a comment to a message and are only used on Sequence diagrams.

    脚本通常用于在消息中添加注释,并且仅用于循序图(时序图)。

    •They are usually placed on the left sideof the diagram, opposite the message they refer to.

    它们通常放置在图的左侧,与它们所引用的消息相反。

    Working with Classes

    •There are several types of classes including regularclasses, parameterized classes, instantiated classes, class utilities, and soon.   有几种类型的类,包括常规类,参数化类,实例化类,类实用程序等。

    Class Stereotypes

    •A stereotype is a mechanism you can use to categorize your classes.

    构造型是一种可用于对类进行分类的机制。

    •Stereotypes also help in the code-generation process.      Stereotypes也有助于代码生成过程

    Analysis Stereotypes

    •There are three primary class stereotypes in UML that are used for analysis: boundary, entity, and control.

    UML中有三种主要的类构造型用于分析:边界,实体和控制。

    Boundary Classes       边界类

    Boundary classes are those classes that lieon the boundary between your system and the rest of the world. These wouldinclude all of your forms, reports, interfaces to hardware such as printers orscanners, and interfaces to other systems.

    边界类位于系统与世界其他地方之间边界上的类。 其中包括所有表单,报告,与打印机或扫描仪之类的硬件的接口以及与其他系统的接口。

    •At a minimum, there must be one boundary class for every actor–use case interaction. The boundary class is what allows the actor to interact with the system. Two actors might both use the same boundary class to communicate with the system. 

    对于每个参与者-用例交互,至少必须有一个边界类。 边界类是允许参与者与系统进行交互的类。 两个参与者可能都使用相同的边界类与系统进行通信。

    Entity Classes       实体类

    •Entity classes hold information that you may save to persistent storage.

    实体类保存您可以保存到持久性存储中的信息。

    •Each attribute in an entity class may become a field in the database.

    实体类中的每个属性都可以成为数据库中的一个字段。

    Control Classes    控制类

    •Control classes are optional, but if a control class is used, there is typically one control class per use case.

    控件类是可选的,但是如果使用控件类,则每个用例通常只有一个控件类。

    •The control class doesn't carry out any functionality itself, and other classes don't send many messages to it. Instead, it sends out a lot of messages.

    控件类本身不执行任何功能,其他类也不向其发送太多消息。 相反,它发出很多消息。

    •They execute alternative flows and know what to do in case of an error. For this reason, control classes are sometimes called manager classes.    

    他们执行替代流程并知道发生错误时的处理方法。 因此,控制类有时称为管理器类。

    Class Types   类的种类

    •In design, we want to categorize our classes using the terminology of the particular programming language we are going to use.      在设计中,我们希望使用将要使用的特定编程语言的术语对类进行分类。

    •Rose supports a number of different stereotypes for its different language options.

    对于不同的语言选项,Rose支持许多不同的构造型。

    Parameterized Class   参数化类别

    •A parameterized class, the first of the special typesof classes we'll discuss, is a class that is used to create a family of otherclasses.    参数化类(我们将讨论的特殊类型的第一种)是用于创建其他类族的类。

    •The arguments for the class are displayed in the dashed-line box.

    类的参数显示在虚线框中。

    Instantiated Class       实例化类

    •An instantiated class is a parameterized class that has actual values for the arguments. UML notation for an instantiated class is a class with the argument name enclosed in angle brackets (< >):

    实例化的类是参数化的类,具有参数的实际值。 实例化类的UML表示法是一个类,其参数名称包含在尖括号(<>)中:

    Class Utility

    •A class utility is a collection of operations. that are used throughout the system but don't fit well into any particular class. These functions can be gathered together and encapsulated into a class utility for use by the other classes in the system.

    类实用程序是方法的集合。 在整个系统中使用,但不适用于任何特定类。 这些功能可以收集在一起并封装到一个类实用程序中,以供系统中的其他类使用。

    •A class utility will appear as a shadowed class on the diagram with this symbol:

    类实用程序将在图中带有以下符号的阴影类中显示:

    Parameterized Class Utility      参数化类实用程序

    •A parameterized class utility is a parameterized class that contains a set of operations. It is the template that is used to create class utilities. It appears on a Class diagram with the following symbol:

    参数化类实用程序是包含一组操作的参数化类。 它是用于创建类实用程序的模板。 它显示在类图上,带有以下符号:

    Instantiated Class Utility   实例化的类实用程序

    •An instantiated class utility is a parameterized class utility that has values set for the parameters. It appears on a Class diagram as follows:      

    实例化的类实用程序是已为参数设置值的参数化类实用程序。 它在类图上显示如下:

    Web Modeling Stereotypes

    •Using this feature, you can more thoroughly describethe structure of your web applications, labeling which classes in the modelcorrespond to client pages, server pages, applets, session objects, or otherweb constructs.

    使用此功能,您可以更彻底地描述Web应用程序的结构,标记模型中的哪些类对应于客户端页面,服务器页面,Applet,会话对象或其他Web构造。

    Setting Class Visibility 设置类的可见性

    •The Visibility option determines whether or not aclass can be seen outside of its package. There are three visibility optionsfor a class:

    可见性选项确定是否可以在包的外部看到类。 一个类有三个可见性选项:

    PublicSuggeststhat the class can be seen by all of the other classes in the system.

    Public  建议类可以被系统中的所有其他类看到。

    Protected or PrivateSuggeststhat the class can be seen in nested classes, friends, or within the sameclass. 

    Protected or Private   建议在类中可以在嵌套类,friends中或同一类中看到类。

    Package or ImplementationSuggests that the class can be seen only by other classes in the same package.  PackageImplementation     建议该类只能由同一包中的其他类看到。

    access violation   访问冲突

    •An access violation occurs in one of two situations:    在以下两种情况之一中发生访问冲突

    • §When there is a relationship between twoclasses in different packages, but there is no dependency relationship betweenthe packages themselves

    当不同包中的两个类之间存在关系时,但包本身之间没有依赖关系

    • §When there is a relationship between classes in different packages, and the supplier class has implementation visibility            当不同包中的类之间存在关系并且供应商类具有实现可见性时

    Setting Class Multiplicity  设置类多重性

    •The Multiplicity field gives you a place to set the number of instances that you expect to have of a class.

    “多样性”字段为您提供了一个位置,用于设置您希望一个类拥有的实例数。

    相关文章

      网友评论

          本文标题:SAD Chapter 6: Behavioral Modeli

          本文链接:https://www.haomeiwen.com/subject/cxajkltx.html