First knowledge of UML

Source: Internet
Author: User
Tags dashed line

Recent study, encountered several UML diagram, is very confused, the exact said, do not understand. Consult UML related material, basically solve this problem. UML still seems rather esoteric, and here is just a little bit of knowledge about solving the problem. (The following knowledge is from the network)

Unified Modeling Language (UML), also known as the Unified Modeling language or standard modeling language, is an OMG standard that began in 1997 and is a graphical language that supports modelling and software system development, providing modeling and visualization support for all phases of software development, Includes requirements analysis to specification, to construction and configuration. The development of object-oriented analysis and Design (Ooa&d,ooad) method There was a climax in the late 80 to 90, and UML was the product of this climax. It not only unifies the representations of Booch, Rumbaugh and Jacobson, but also develops them further and eventually unifies the standard modeling language accepted by the public. The UML specification is used to describe the concepts of modeling, such as classes (objects), objects, associations, responsibilities, behaviors, interfaces, use cases, packages, sequences, collaborations, and states.

The most commonly used UML diagrams are: Use case diagrams, class diagrams, Sequence diagrams, state diagrams, activity diagrams, component diagrams, and deployment diagrams. Let's talk about use case diagrams, class diagrams, Sequence diagrams.

Use case diagram

A use case diagram describes a functional unit provided by the system. The primary purpose of the use case diagram is to help the development team understand the functional requirements of the system in a visual way, including the "role" of the basic process (actors, which is the other entity interacting with the system), and the relationship between the use cases within the system. A use case diagram typically represents an organization relationship for a use case-either the entire system's use case or a set of use cases that have functionality (for example, all security management-related use cases). To display a use case on a use case diagram, draw an ellipse, and then place the name of the use case in the center of the ellipse or in the middle position below the ellipse. To draw a character (representing a system user) on a use case diagram, you can draw a humanoid symbol. The relationship between roles and use cases is described using a simple line segment, shown in 1.

              Figure 1: Example use case diagram

Graphic (top to bottom): CD sales system; View the sales statistics of the band CD; View Billboard 200 leaderboard report; record Manager; View sales statistics for specific CDs; Retrieve the latest Billboard 200 leaderboard report; Leaderboard Reporting Service

Use case diagrams are often used to express the advanced functionality of a system or system category. 1, it is easy to see the features that the system provides. This system allows the band manager to view the sales statistics report for the band CD as well as the Billboard 200 leaderboard report. It also allows record managers to view sales statistics for specific CDs and reports of these CDs in the Billboard 200 leaderboard. This diagram also tells us that the system will provide a billboard leaderboard report through an external system called leaderboard Reporting Services.

In addition, in use case diagrams, the use cases that are not listed indicate the functionality that the system cannot perform. For example, it does not provide a way for the band manager to listen to songs from different albums on Billboard 200-that is, the system does not refer to a use case called "listening to songs on Billboard 200". This lack is not a small thing. Providing clear, concise use-case descriptions in use case diagrams makes it easy for project sponsors to see if the system provides the necessary functionality.

Class diagram

A class diagram represents how different entities (people, things, and data) relate to each other, in other words, it shows the static structure of the system. Class diagrams can be used to represent logical classes, usually the kind of things that business people talk about-rock bands, CDs, radio dramas, or loans, mortgages, car credits, and interest rates. Class diagrams can also be used to represent implementation classes, which are entities that programmers work with. The implementation class diagram may display some of the same classes as the logical class diagram. However, implementing a class diagram does not use the same attributes to describe it, because it is likely to have a reference to things like vectors and hashmap.

The class is described by using a three-part rectangle on the class diagram, as shown in 2. The top section shows the name of the class, the middle part contains the properties of the class, and the bottom part contains the operation of the class (or "method").

  Figure 2: Example Class object in a class diagram

Draws an inheritance relationship 1 using a line segment with arrows pointing to the parent class, and the arrow should be a complete triangle. If all two classes know each other, you should use a solid line to represent the relationship, and if only one of the classes knows the association, use the open arrow to indicate it.

        Figure 3: A complete class diagram, including the class object shown in Figure 2

In Figure 3, we see both the inheritance and the two association relationships. The Cdsalesreport class inherits from the report class. A Cdsalesreport class is associated with a CD class, but the CD class is unaware of any information about the Cdsalesreport class. Both the CD class and the band class know each other, and two classes can be associated with one or more other classes.

Sequence diagram

A sequence diagram shows a detailed process of a specific use case (or part of a use case). It is almost self-describing and shows the invocation relationships between different objects in the process, as well as displaying different calls to different objects in great detail.

Sequence diagrams have two dimensions: the vertical dimension displays the sequence of messages/calls in the chronological order in which they occur, and the horizontal dimension displays the object instances to which the message is sent.

The plotting of sequence diagrams is very simple. Across the top of the graph, each box (see Figure 4) Represents an instance (object) of each class. In the box, the class instance name and the class name are separated by a space/colon/space, for example, Myreportgenerator:reportgenerator. If a class instance sends a message to another instance of the class, draw a line with an open arrow pointing to the receiving class instance and place the name of the message/method on the wire. For some particularly important messages, you can draw a dashed line with an open arrow pointing to the originating class instance and label the return value on the dashed line. As far as I'm concerned, I always like to draw a dashed line that includes the return value, and this extra information makes the sequence diagram easier to read.

Reading the sequence diagram is also very simple. Start with the "drive" class instance in the upper-left corner of the sequence and read down through each message. Remember: Although the example sequence diagram shown in Figure 4 shows the return message for each message being sent, it is optional.

            Figure 4: A sample sequence diagram

By reading the example sequence diagram in Figure 4, you can see how to create a CD sales report. Where the Aservlet object represents the drive class instance. Aservlet sends a message to the Reportgenerator class instance named Gen. The message is marked as Generatecdsalesreport, indicating that the Reportgenerator object implements the message handler. Further understanding it can be found that the Generatecdsalesreport message label includes a cdid in parentheses, indicating that Aservlet passes a parameter named Cdid with the message. When the Gen instance receives a Generatecdsalesreport message, it then calls the Cdsalesreport class and returns an instance of Acdreport. The Gen instance then invokes the returned Acdreport instance and passes the arguments to it each time the message is called. At the end of the sequence, the Gen instance returns a acdreport to its caller, Aservlet.

First knowledge of UML

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.