Результаты (
английский) 1:
[копия]Скопировано!
UML basics: The sequence diagramFrom The Rational Edge series of articles,.UML basics, on the essential diagrams in the Unified Modeling Language, this article offers a detailed introduction to the sequence diagram. It also introduces several new elements in the recent notation, UML 2.0 specification.View more content in this series | 38 CommentsShare:InGoogle + FacebookTwitterLinkedDonald Bell (bellds@us.ibm.com), IT Architect, IBM Corporation16 February 2004Also available in Chinese Vietnamese-Try related software+Table of contentsDevelop and deploy your nextthe app on the IBM Bluemixcloud platform.Start building for freeIllustrationIt's February, and by now you've probably read or heard about, people talked about, making the change to the UML 2.0-the new specification for UML that contains a number of the date. Given the importance of the new spec, we are changing the basis of this article series, too, shifting our attention from the UML 1.4 Specification OMG's to OMG's Adopted 2.0 Draft Specification of UML (a.k.a. UML 2). I hate to change emphasis from 1.4 to 2.0 in the middle of a series of articles, but the UML 2.0 Draft Specification is an important step forward, and I feel the need to spread the word.There were a couple of reasons that the OMG UML improved. The main reason was that they wanted the UML models to be capable of delivering the Model Driven Architecture (MDA), which meant that the UML had to function as a more model driven notation. Also, the UML 1. x notation set was at times difficult to apply to larger applications. Furthermore, the notation elements needed to be improved in order to make diagrams more readable. (For example, logical flow modeling in UML 1. x was complicated and at times impossible. Changes to the sequence diagram's set in UML 2 notation have made vast date in modeling logic in sequences.)Resources we think you'll likeIBM Rational Software Architect wikiEvaluate IBM Rational Software Architect:Create editable sequence diagram with Rational Software ArchitectCreate editable sequence diagrams with Rational Software ArchitectIBM Rational Software Architect communityRational Software Architect product evolution, all the what's new in all the versions.Notice the wording in my statement above: "Adopted a Draft Specification of UML 2.0." It is true that the specification is still in draft status, but the key is that the Draft Specification has been adopted by OMG, a consortium that does not adopt the new standards until they become pretty solid. There will be some changes to the specification before UML 2 is completely adopted, but these changes should be minimal. The main changes will be in the internals of the UML-involving the features typically used by software companies who implement UML tools.The main purpose of this article is to continue our focus on the essential UML diagrams; This month, we take a close look at the sequence diagram. Please note, again, that the examples provided below are based on the new UML 2 specification.The diagram's purposeThe sequence diagram is used primarily to show the interactions between objects in the sequential order that those interactions to occur. Much like the class diagram, developers typically think sequence diagrams were meant exclusively for them. However, an organization's business staff can find the sequence diagrams are useful to communicate how the business currently works by showing how various business objects interact. Besides documenting an organization's current affairs, a business-level sequence diagram can be used as a requirements document to communicate the requirements for a future system implementation. During the requirements phase of a project, can take will use cases to the next level by providing a more formal level of refinement. When that occurs, use cases are often refined into one or more sequence diagrams.An organization's technical staff can find the sequence diagrams are useful in documenting how a future system should behave. During the design phase, architects and developers can use the diagram to force out the system's object interactions, thus fleshing out overall system design.Deploy with confidenceConsistently deliver high-quality software faster using DevOps services on IBM Bluemix. Sign up for a free Bluemix cloud trial, and get started.One of the primary uses of sequence diagrams is in the transition from requirements expressed as use cases to the next and more formal level of refinement. Use cases are often refined into one or more sequence diagrams. In addition to their use in designing new systems, sequence diagrams can be used to document how the objects in an existing (call it "legacy") system currently interact. This documentation is very useful when transitioning a system to another person or organization.Back to topThe notationSince this is the first article in my UML diagram series that is based on the UML 2, we need to first discuss an addition to the notation in UML 2 diagrams, namely (a) the notation element is called a frame. The frame element is used as a basis for many other elements in UML 2 diagram, but the first place most people will encounter a frame element is as the boundary of a graphical diagram. A frame element provides a consistent place for a diagram's label, while providing a boundary for the graphical diagram. The frame element is optional in the UML diagrams; as you can see in Figures 1 and 2, the diagram's label is placed in the top left corner in what I'll call the frame's "namebox," a sort of dog-eared rectangle, and the actual UML diagram is defined within the body of the larger enclosing rectangle.Figure 1: An empty UML 2 frame elementAn empty UML 2 frame elementIn addition to providing a visual border, the frame element also has an important use in functional diagrams depicting the interactions, such as the sequence diagram. Sequence diagrams on incoming and outgoing messages (a.k.a. interactions) for a sequence can be modeled by connecting the messages to the border of the frame element (as seen in Figure 2). This will be covered in more detail in the "Beyond the basics" section below.Figure 2: A sequence diagram that has incoming and outgoing messagesA sequence diagram that has incoming and outgoing messagesNotice that in Figure 2 the diagram's label begins with the letters "sd" for Sequence Diagram. When using a frame element to enclose a diagram, the diagram's label needs to follow the format of:Diagram The Diagram Type NameThe UML specification provides specific text values for diagram types (e.g., sd = Sequence Diagram, activity Diagram, Activity = and = use case Use Case Diagram).Back to topThe basicsThe main purpose of a sequence diagram is to define event sequences that result in some desired outcome. The focus is less on the messages themselves and more on the order in which messages occur; Nevertheless, most sequence diagrams will communicate what messages are sent between a system's objects, as well as the order in which they occur. The diagram conveys this information along the horizontal and vertical dimensions: the vertical dimension shows, top down, the time sequence of messages/calls as they occur, and the horizontal dimension shows, left to right, the object instances that the messages are sent to.LifelinesWhen drawing a sequence diagram, the lifeline of the notation elements are placed across the top of the diagram. Lifelines represent either roles or object instances that participate in the sequence being modeled. [Note: In fully modeled systems the objects (instances of classes) will also be modeled on a system's class diagram.] Lifelines are drawn as a box with a dashed a great line descending from the center of the bottom edge (Figure 3). The lifeline's name is placed inside the box.Figure 3: An example of the Student class used in a lifeline whose instance name is freshmanAn example of the Student class used in a lifeline whose instance name is freshmanThe UML standard for naming a lifeline follows the format of:Instance Name: Class NameIn the example shown in Figure 3, the lifeline represents an instance of the class Student, whose instance name is a freshman. Note that, here, the lifeline name is underlined. When an underline is used, it means that the lifeline represents a specific instance of a class in a sequence diagram, and not a particular kind of instance (i.e., a role). In a future article we'll look at structure modeling. For now, just observe that sequence diagrams may include roles (such as buyer and seller) without specifying who plays those roles (such as Bill and Fred). This allows diagram reuse in different contexts. Simply put, instance names in sequence diagrams are underlined; the names of the roles are not.Our example lifeline in Figure 3 is a named object, but not all lifelines represent named objects. Instead a lifeline can be used to represent an anonymous or unnamed instance. When modeling an unnamed instance on a sequence diagram, the lifeline's name property follows the same pattern as a named instance. but instead of providing an instance name, that portion of the lifeline's name is left blank. Again referring to Figure 3, if the lifeline is representing an anonymous instance of the Student class, the lifeline would be: "Student." Also, because the sequence diagrams are used during the design phase of projects, it is completely legitimate to have an object whose type is unspecified: for example, "the freshman."MessagesThe first message of a sequence diagram always starts at the top and is typically located on the left side of the diagram for readability. Suggested messages are then added to the diagram slightly lower then the previous message.To show an object (i.e., lifeline) sending a message to another object, you draw a line to the receiving object with a solid arrowhead (if a synchronous call operation) or with a stick arrowhead (if an asynchronous signal). The message/method name is placed above the arrowed line. The message that is being sent to the receiving of ob
переводится, пожалуйста, подождите..
