Nine kinds of legend analysis _uml of UML

Source: Internet
Author: User
Tags dashed line
Relationships between classes in UML diagrams: dependencies, generalizations, associations, aggregations, combinations, implementations
Class and Class Diagram 1) Class (class) encapsulates data and behavior and is an important component of object-oriented, which is a generic term for objects with the same attributes, operations, and relationships. 2 in the system, each class has a certain responsibility, the responsibility refers to the tasks of the class, that is, what kind of function to complete, what kind of obligations to bear. A class can have multiple responsibilities, and a well designed class typically has only one responsibility, and when defining a class, it breaks down the responsibility of the class into the properties and operations of the class (i.e., the method). 3 class's attribute is the class's data duty, the class's operation is the class's behavior duty


I. Dependencies (dependence)

Dependencies (dependence): Assuming that Class A changes cause a change in class B, the name B class relies on Class A.

• Dependency (Dependency) is a usage relationship in which the change of a particular thing may affect other things that use it, and use dependencies when it is necessary to represent one thing using another. In most cases, dependencies are embodied in the method of a class using an object of another class as a parameter. • In UML, a dependency is represented by a dotted line with an arrowhead, and the dependent party points to the dependent party.
public class Driver {public void drive (car car) {car.move ();   } ...... }       public class Car {public void move () {...} ...... }

Dependencies have the following three scenarios:

1. Class A is a local variable in class B (a method);

2. Class A is a parameter of class B method;

3. Class A sends messages to class B, thus affecting class B changes;


Ii. generalization relations (generalization)

Generalization relations (generalization): A is the parent class of B and C, B,c has a public class (parent) A, stating that A is the generalization (generalization, also called generalization) of B,c.

• Generalization relations (generalization), also known as "is-a-kind-of" relationships, are used to describe the relationship between a parent class and a subclass, and a parent class is also called a base class or superclass, and a subclass is also called a derived class. In UML, a generalization relationship is represented by a straight line with a hollow triangle. • Use object-oriented inheritance mechanisms to implement generalization relationships when code is implemented, such as using the extends keyword in the Java language and using the colon ":" in c++/c#.


public class person    {       protected string  name;       protected int age;        public void move ()         {            ......       }        Public void say ()        {            ......       }  }   public class  student extends person    {       private string  studentNo;       public void study ()          {           ......        }  }  

In UML, there are three requirements for generalization relationships:

1, the subclass and the parent class should be exactly the same, the parent class has attributes, operations, subclasses should have;

2. In addition to the same information as the parent class, additional information is included in the subclass.

3, can use the instance of the parent class place, also can use subclass of instance;

III. Association Relations (Association)

Association Relationship (Association): The relationships between classes, such as customers and orders, each order corresponds to a specific customer, each customer corresponds to some specific order, and then the link between the basketball player and the team (shown below).


Among them, "employee" and "employer" on both sides of the association indicate the relationship between the two, and the number means the restriction of the relationship between the two, which is the multiplicity of the correlation. There is usually a "*" (means all, no limit), "1" (indicating there is and only one), "0 ..." (representing 0 or more), "0,1" (for 0 or one), "N...M" (for N to M), "m...*" (for at least m).

• Association Relationship (association) is the most commonly used relationship between classes and classes, which is a structured relationship between a class of objects and another class of objects. • In UML class diagrams, objects that are associated with a solid line are connected by a class that, when implemented in a programming language such as Java, C #, and C + +, typically uses the object of one class as the property of another class. • The role name can be annotated on the association line when a class diagram is used to represent an association relationship.
1 Bidirectional Association: By default, the association is bidirectional.

public class customer   {       private product[]  products;       ......  }   public class product    {       private Customer customer;        ......  }  

2 One-way Association: The Association of the class can also be one-way, one-way association with a solid line with an arrow to express.
public class, Customer {private address;      ...... }     public class Address {...} 3 autocorrelation: There may be some classes in the system where the attribute object type is the class itself, and this particular association relationship is called the autocorrelation.
public class Node {private Node subnode; ...... }
4) Multiplicity Correlation: The multiplicity association relation is also called the Multiple association Relation (multiplicity), which represents the number of objects of one class and the object of another class. In UML, multiple relationships can add a number to the associated line directly to represent the number of objects of another class corresponding to it.

Presentation method

Multiplicity of descriptions

1..1

An object representing another class is related to only one object of that class

0..*

An object representing another class has a relationship with 0 or more of the class object

1..*

An object representing another class is associated with one or more of the class objects

0..1

An object representing another class has no or only relationship to one of the class objects

M.. N

An object representing another class has a relationship with the least m, up to n objects of that class (M<=n)

public class Form {private Button buttons[];    ...... } public class Button {...}


Iv. Aggregation relations (Aggregation)

Aggregation relationship (Aggregation): The whole and part of the relationship, the whole and part can be separated.

• The aggregation relationship (Aggregation) represents a relationship between a whole and a part. Usually after defining a whole class, we analyze the structure of the whole class to find out some member classes, which form the aggregation relationship between the whole class and the member class. • In an aggregation relationship, a member class is part of a whole class, that is, a member object is part of a whole object, but a member object can exist independently of the whole object. In UML, an aggregation relationship is represented by a straight line with a hollow diamond.

public class Car {private Engine Engine;       Public car (Engine Engine) {this.engine = Engine;       public void Setengine (Engine Engine) {this.engine = Engine;   } ...... } public class Engine {...}

such as: telephone including a microphone

Computers, including keyboards, monitors, a computer can be with multiple keyboards, multiple monitors with, to determine the keyboard and monitor can be separated from the host, the host can choose other keyboards, monitors composed of computers;


V. Combinatorial relations (composition)

Combinatorial relations (composition): The relationship between the whole and the part, but the whole and the part can not be separated.

• Combinatorial relationships (composition) also represent the overall and partial relationships between classes, but there is a unified lifetime of the parts and the whole in a composite relationship. Once the whole object does not exist, some objects will not exist, and part of the object and the whole object have the relationship between the die and die. • In a composite relationship, the member class is part of the overall class, and the overall class can control the life cycle of the member class, that is, the existence of the member class depends on the overall class. In UML, a composite relationship is represented by a straight line with a solid diamond.

public class Head {private mouth mouth;       Public head () {mouth = new mouth ();      } ...... } public class Mouth {...}

Such as: Companies and departments, the department is part of the company is a whole, the company A's finance department can not and Company B of the financial department of the swap, that is, the company A can not be separated from their own financial department; the heart of Man and man.


Vi. Implementation of relations (Implementation)

Implementation relationship (Implementation): A class or build structure that is used to specify interfaces and solid interfaces, and interfaces are collections of operations that are used to specify a class or a service that is built.

• Interfaces can also have inheritance relationships and dependencies similar to those of classes, but there is an implementation relationship (realization) between interfaces and classes in which the class implements the interface, and the operations in the class implement the actions declared in the interface. In UML, the implementation relationship between a class and an interface is represented by a dashed line with a hollow triangle.

Public interface Vehicle {public void move ();   } public class ship implements Vehicle {public void Move () {...}   public class car implements Vehicle {public void Move () {...} }

Overview of the 9 legend in UML

As a modeling language, UML definitions include two parts of UML semantics and UML notation.

UML semantics: Describes the precise Metamodel definition based on UML.

L UML notation: Defines the notation for UML notation and provides a standard for system modeling using these graphical symbols and text syntax for developers or development tools. These graphical symbols and literals represent the application-level model, which is semantically an instance of the UML meta model.

The standard modeling language UML can be defined by the following 5 class diagrams.

L use case diagram: Describes the system function from the user's point of view and points out the operator of each function.

L Static diagram: Includes class Diagram and object graph. Class diagrams describe the static structure of classes in a system, not only the classes in the system, the relationships between classes, such as associations, dependencies, aggregations, etc., but also the attributes and operations of classes, which describe a static relationship that is valid throughout the life cycle of the system. An object graph is an instance of a class diagram that uses exactly the same identity as the class diagram. An object graph is an instance of a class diagram. Because the object has a lifecycle, the object graph can exist only at one time in the system.

L Behavioral Graph: Describes the interaction between the dynamic model of the system and the constituent objects, including state and activity diagrams. The state diagram describes all possible states of the object of the class and the transition conditions of the state at the time of the event, and the state diagram complements the class diagram, which describes the activities to be performed to satisfy the use-case requirements and the constraint relationships between activities, which facilitates identification and activity.

L Interaction diagram: Describes the interaction between objects, including sequence diagrams and collaboration diagrams. The sequence diagram shows the dynamic cooperative relationship between objects, it emphasizes the order of messages sent between objects, and displays the interaction between objects, collaboration diagram describes the collaboration between objects, collaboration diagram and sequence diagram, show the dynamic cooperative relationship between objects. In addition to displaying information exchange, a collaboration diagram displays objects and their relationships. If you emphasize time and order, use a sequence diagram, and if you emphasize a subordinate relationship, select the collaboration diagram.

• Implementation diagram: Includes component diagrams and deployment diagrams. The component diagram describes the physical structure of the code part and the dependencies between the parts, and the component diagram helps to analyze and understand how the parts interact; The deployment diagram defines the physical architecture of the hardware and software in the system.

When using UML to design a system, the first step is to describe the requirement and the second step is to establish the static model of the system to construct the structure of the system; The third step is to describe the behavior of the system. The models established in the first step and the second step are static, which includes 5 kinds of graphs, such as use case diagram, Class diagram, object graph, Component diagram and deployment diagram, and is the static modeling mechanism of UML in standard modeling language. The model established in the third step can either execute or represent the timing state or interaction between execution. It includes 4 kinds of graphs, such as state diagram, activity diagram, sequence diagram and collaboration diagram, which is the dynamic modeling mechanism of UML in standard modeling language.

The

First makes a brief introduction to the functions of each diagram in UML: 1, use case diagrams     describe roles and the connection between roles and use cases. It shows who is going to use the system and what they can do with the system. A use case diagram contains multiple model elements, such as systems, actors, and use cases, and shows the various relationships between these elements, such as generalization, association, and dependencies. 2. Class diagrams     class diagrams are static views that describe the classes in the system and the relationships between the classes. Enables us to have a comprehensive understanding of the system before we write the code correctly. A class diagram is a type of model, or rather, a static model type. 3, object graph     and class diagram is very similar, it is a class diagram instance, object graph shows the class of multiple object instances, rather than the actual class. It describes not the relationships between classes, but the relationships between objects. 4, Activity diagram     describe the activities to be carried out by the use case requirements, and the constraint relationship between activities, which facilitates the identification of parallel activities. The ability to demonstrate where functions exist in the system, and how these functions and other components of the system work together to meet the business needs of the previous use case diagram modeling. 5, State diagram     describe all possible states of the object of the class, and the transition condition of the state when the event occurs. You can capture the lifecycle of objects, subsystems, and systems. They can tell how an object can have a state, and how events (such as the receipt of messages, the passage of time, errors, conditions, and so on) will affect these states over time. A statechart diagram should be connected to all classes that have a clear identifiable state and complex behavior, which can determine the behavior of the class and how the behavior changes according to the current state, or show which events will change the state of the object of the class. A state diagram is a supplement to a class diagram. 6. Sequence diagram (sequence diagram)     sequence diagram is a model to show how your participants interact with the system's objects in a sequence of steps. A sequence diagram can be used to show how objects interact with each other. The sequence diagram focuses on the message sequence, emphasizing how messages are sent and received between objects. 7. Collaboration Diagram

Similar to sequence diagrams, shows the dynamic partnership between objects. Can be seen as the intersection of class diagrams and sequential graphs, collaboration diagrams modeling objects or roles, and how they communicate with each other. If you emphasize time and order, use sequence diagrams, and if you emphasize superior-subordinate relationships, select a collaboration diagram, which is called an interaction diagram. 8, Component diagram (Component diagram) describes the physical structure of the code component and the dependencies between the various constructs. The components that are used to model software and their relationships with each other, these graphs are composed of the relationship between the component markers and the components. In a component diagram, a component is a single part of the software, which can be a file, product, executable, and script. 9, deployment diagram (configuration diagram) is used to model the physical deployment of the system. such as computers and devices, and how they are connected. The users of the deployment diagram are developers, system integrators, and testers. The difference between several graphs:

One: These nine kinds of models have their own emphasis,

1: Use case diagrams focus on describing user needs,

2: Class diagram focuses on the description of the system specific implementation;

Two: The description of the aspects are not the same,

1: The class diagram describes the structure of the system,

2: The sequence diagram describes the behavior of the system;

Three: The level of abstraction is also different,

1: Component diagram describes the system's modular structure, higher levels of abstraction,

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.