UML (Unified Modeling Language) Unified Modeling Language

Source: Internet
Author: User

What is a model

Model is a simplification of the reality

A model is a blueprint for providing a system, but the model includes a detailed plan. It is also the overall plan for a higher degree of consideration of the system, and each system can be described in different ways by models that are not passed. Thus, each model is a semantically closed abstract system. The model can be structural, emphasizing the organization of the system. It is also behavioral, emphasizing the dynamic aspects of the system.

Example: Sales center inside the real estate blueprint

Why modeling

Modeling is designed to better understand the systems under development

By modeling to achieve the following purposes
1, the model helps to visualize the system according to the actual situation or according to the desired style
2. The model can regulate the structure or behavior of the system
3, the model gives the template of the construction system
4, the model to make the decision to document
The greater the importance of modeling a complex system, such as banking and telecommunications systems. If you do not understand a complex system, blind development, the likelihood of failure is very large.

What is UML

The Unified Modeling Language (Unified Modeling Language, UML) is a standard language for drawing software blueprints that can be visualized, detailed, structured, and documented in UML for software-intensive products
1. Visualization: Clear model facilitates communication
2, Detailed: You can use UML to analyze, design, implementation and other decisions to describe in detail
3. Construct: Map UML description into programming language
4, Documentation: all the details of the system can be described in UML. Such as: project planning, release activities, etc.

Application fields:

1. Enterprise Information System
2. Banking and financial Services
3, Telecommunications
4. National defense, Aerospace
5. Science
6. Web-based distributed services

Modeling tools Here I am using the VS2012 self-brought.

FILE--New--Project--Modeling project

First, class diagramClass 1.1

When a group of objects (object) enjoys the same structure, behavior, constraints, and semantics, they are called objects of the same class. In other words, defining a class is equivalent to describing a group of objects. In a class, the structure of an object is expressed using an attribute (attribute), and the action (operation) is used to express the object's behavior.

A class is a set of object descriptions with the same properties, operations, relationships, and semantics, but one class implements one or more interfaces. The diagram on the left is a graphical representation of the class in. Net

1.1.1 Visibility and Abstraction classes

UML Presets Four visibility, public, private, protection (protected), Packages (package) minus (-) for private visibility, plus (+) for public visibility

In UML the abstract class is the same as the normal one is the graph representation, but the name will become italic.

1.2 Relationship

Relationship is the connection between things, in object-oriented modeling, there are three important relationships are dependency, generalization, association

1.2.1 Dependency (Dependency)

Dependency is a use relationship, one thing uses another. On the graph, the dependency is drawn as a dashed line with a direction pointing to the object being relied upon. If the class being used changes, then the operation of the other class is bound to be affected

Dependency This is a typical temporary relationship that represents a brief interaction between classes. dependencies are represented in. NET languages as local variables, parameters of methods, or calls to static methods, such as tool classes, real-life people and hammers.

1.2.2 Generalization (generalization)

In a generalization relationship, a subclass inherits the behavior and meaning of the parent class, and the subclass can also add new behaviors and meanings or overwrite the behavior and meaning in the parent class. On the graph, draw in a generalization with a hollow triangle line pointing to the parent class

Generalization in. NET is an inheritance relationship

1.2.3 Association (Association)

An association is a structural relationship that indicates the relationship between an object and another object.

ClassA and CLASSB are interrelated
Correlation is a kind of strong dependency between two classes, or the semantic level between classes and interfaces, and is a long-term stable relationship; At the code level, the associated class appears in the association class as a class attribute, or the association class refers to a global variable of the type being associated class.
One-Way Association
ClassA related to CLASSB


A one-way association is represented at the code level, in which the associated Class B appears as a class attribute in the association Class A, or the association Class A refers to a global variable of the type being associated with Class B;

1.2.3.1 Aggregation Relationship (Aggregation)


Aggregation is a special case of association, and he embodies the relationship between the whole and the part. At this point the whole and the parts are separable, they can have their own life cycle, some can belong to more than one whole object, can also be shared for multiple whole objects, such as automobiles and engines; performance at the code level, and the association is consistent, only from the semantic level to distinguish

1.2.3.2 combination Relationship (composition)


The combination is also a special case of the relationship, which is stronger than aggregation, also known as strong aggregation; he also embodies the relationship between the whole and the part, but at this time the whole and the part is not divided, the whole life cycle end also means that part of the life cycle ends; a pregnant woman dies, and the fetus naturally dies; is consistent with association relationships and can only be differentiated from the semantic level

The multiplicity of 1.2.3.3 correlation relation


Bidirectional affinity is not recommended. An association has two endpoints, which can have a cardinality at each endpoint, indicating that the associated class can have several instances.
Common cardinality and meaning
A 0..1:0 or 1 instance.
0..*: There is no limit to the number of instances.
1: There can be only one instance.
1..*: There is at least one instance.

1.3 Interface

Interface (interface) is like a contract, and the responsible class must be responsible for implementing its public operations, and for maintaining its public properties

Case: Company-department-employee class diagram relationship

1.4 Forward Engineering, reverse engineering

Forward Engineering: UML Diagram Generation code
Right-click directly on the diagram and select "Generate Code" to complete the forward engineering
Reverse engineering: generating UML Diagrams from code
From the Architecture Explorer, find the type of class that requires reverse engineering and drag it to the UML diagram. Or you can find the type of class in the project and drag it into the project to complete reverse engineering.


Note: In reverse engineering, the absolute path of the class cannot appear in Chinese

Second, use case diagram 2.1 use case diagram description

Use case diagrams are used to express the services or functions provided by the system, and are suitable for use as a requirement gathering phase.

2.2 Use cases and performers

Common use Cases (UseCase) to express system requirements or the behavior of the system externally, use the ellipse diagram, the actor (actor) is a human-type diagram, because it will participate in the operation of the system, so it is connected with the use case between the line segment


The behavior of the ATM can be divided into three different use cases, namely, withdrawals, deposits, plus money. Automatic teller machine outside a total of two participants will participate in the behavior of the ATM, one named the user, and the other called the bank. The customer participates in the first two use cases and should participate in the last use case

2.3 Inclusive relationships (include)

The inclusion (include) relationship refers to the relationship between two use cases, where the behavior of one of the use cases (referred to as basic use cases, Base uses case) contains the behavior of another use case, which is referred to as containing a case. The withdrawal will include a user-validated use case

2.4 Extending relationships

Extended (Extend) Relationship: a relatively independent and optional action in the base use case, encapsulated with an extension (Extension) use case, and then extended from the extension point (Extension points) declared in the base use case, to make the base case behavior more concise and targeted more focused. After we have finished the payment, we can print the bar, or we can not print the article. This feature allows you to use extensions to represent

Third, the activity chart

Activity diagrams are often used to express a sequence of actions in a business process, workflow, or system process


Simple landing process, login failure, jump to landing page, landing successfully jump to the main interface
Each activity diagram can have only one start node, but can have multiple end nodes

3.1 Action and control flow

An activity is the most important constituent element that represents an execution step


A connection line with arrows is called control flow. When the source action is finished, the control flow initiates the target action.

3.2 Object nodes and object flow

The object node is a rectangular diagram, and the object flow diagram is the same as the control flow, but one of its endpoints must be an object node, and the other end must be another node. The two endpoints of a control flow cannot be object nodes. The object flow can carry data or objects, unlike the control flow.

After a successful login, we pass the user object to the next node

If you use an Object node as an active parameter for input or output activities, you can use the active parameter node (activity parameter node) instead. A parameter node is actually an object node.
3.3 Decision-making and merging
In an activity flow, a process junction, called a merge node. A merge node will have multiple entry lines, but there is only one left line, the diagram of the merging node is the large hollow diamond, and all the tributaries that enter the merge node will go through the same exit line.

The decision nodes (decision node) share the diagram with the merge nodes, both of which are large hollow diamonds. However, the decision node has only one entry line, but there are multiple exit lines

3.4 Fork and connection

bifurcation means that a control flow is replaced by two or more control flows, which are carried out concurrently after forking
The connection is just the opposite of a fork, indicating that two or more control flows are replaced by a control flow. Using forks requires a connection to converge the flow of a fork into a stream

3.5 Send signal operation and accept event action

The send signal action is an operation that sends a message or signal to another activity.
An accept event Action is an operation that waits until a message or signal is not resumed.

Iv. sequence diagram (timing diagram)

Sequence diagrams are used to express the interaction of a group of objects within a system, which is a behavior diagram. The horizontal direction is the object dimension, and the vertical direction is the time dimension


The interaction between page and action can be represented by an instance diagram, and we need a return result set when sending a list request

4.1 Lifeline

A lifeline (lifeline) represents an instance of a participating interaction, which is a dashed line at the top of the connecting rectangle, and the rectangle at the top of the dashed line can place the name of the lifeline.

4.2 Execution occurs

An object executes an activity after it receives a message, which is called an execution occurrence (execution occurrence), and its diagram is a long rectangle.

4.3 News

The message is illustrated by a line of arrows that spans over two lifelines, interacting between objects by sending messages.

There are four kinds of common messages in sequence diagrams
Create message (createmessage) the message used to create the object is called the Create message, which is a dashed line with arrows pointing to the target object.
Synchronous Invocation (Synchcall)-This is the most common message. Its illustration is the solid line of the arrow, which points to the target object responsible for execution by the source object that sent the message.

Reply Message (replymessage) at the end of execution of the target object, a reply message is sent to the source object. It is shown as a dashed line with arrows pointing back to the source object from the target object responsible for execution
Asynchronous signal (Asynchsignle) synchronous vs. asynchronous is the difference between whether the source object waits for the target execution to finish before continuing to execute. If the source object sends a synchronous message, it waits, and if it sends an asynchronous message, it does not wait.

4.4 Termination

A lifeline has a life and death, and a stop is a time to express the end of a lifeline. The ending icon is a large fork, placed at the bottom of the dashed line of the lifeline, representing the lifeline has been terminated.

UML (Unified Modeling Language) Unified Modeling Language

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.