Table of Contents
-
- 1. Brief description
- 2. UML composition
- 3. UML things
- 4. UML relationship
- 5. UML diagram
-
- 5.1 Classification of UML diagrams
- 5.2 Structure diagram (static diagram)
-
- 1) class diagram
- 2) Object diagram
- 3) Component diagram
- 4) Deployment diagram
- 5) Product drawing
- 6) Package diagram
- 7) Composite structure diagram
- 5.3 Behavior diagram (dynamic diagram)
-
- 1) Interaction diagram
-
- 1.1) Sequence Diagram (Sequence Diagram/Sequence Diagram)
- 1.2) Communication Diagram (Collaboration Diagram)
- 1.3) Timing Diagram
- 1.4) Interaction overview diagram
- 2) Use case diagram
- 3) Activity Diagram
- 4) State diagram
1. Brief description
What is UML?
UML
, full name Unified Model Language
, Chinese is Unified Modeling Language
, is a standardized modeling language composed of a set of charts, supporting from the demand Analyze the entire process of software development from the beginning.
Why use UML?
By using UML, the entire software design has better readability and comprehension before software development, thereby reducing development risks. At the same time, it can also facilitate the communication between developers.
2. UML composition
Generally speaking, the structure of UML includes three parts: Building Block
, Rule
and Common Mechanism
.
Building block
: UML has three basic building blocks, which arething
,relationship
,diagram )
. Transactions are an important part of UML, relationships closely link transactions together, and diagrams are a collection of multiple associated transactions.Rule
: Refers to the rules for how the building blocks are put together.Common Mechanism
: Refers to a public UML method to achieve a specific goal.
3. UML things
Structural things
: static parts of the model, such as classes, interfaces, use cases, components, etc.;Behavioral things
: dynamic parts of the model, such as interactions, activities, state machines;Group things
: organizational parts of the model, such as packages;Annotation Things
: The interpretive part of a model, a simple notation attached to an element or set of elements that constrains or interprets it.
4. UML relationship
Dependence
: The semantics of one thing depends on the semantics of another thing changes.Association
: is a structural relationship that describes a set of chains, which are links between objects. It is divided intocombination
andaggregation
, both of which are part and whole relationship, wherecombination
Stronger relationships between things. The association between two classes is actually the association of the roles played by the two classes. Therefore, there can be multiple associations identified by different roles between the two classes.Generalization
: general/special relationship, the relationship between subclasses and parent classes.Implements
: A classifier specifies a contract that another classifier guarantees to enforce.
Supplement: What is the difference between aggregation and composition in Java?
Java Aggregation:
class A{<!-- --> public void cc(B b){<!-- --> System.out.println(b.show()); } } class B{<!-- --> public void show(){<!-- --> System.out.println("hello"); } } class C{<!-- --> A a = new A(); B b = new B(); a.cc(b); }
From the above example, it can be seen that the B object is still referenced by the C object after the A object is called, and has not disappeared. So the relationship of B to A with respect to A is aggregation.
Java Composition
class A{<!-- --> public A(){<!-- --> B b = new B(); } b. show(); } class B{<!-- --> public void show(){<!-- --> System.out.println("hello"); } } class C{<!-- --> A a = new A(); }
From the above example, it can be seen that the B object will naturally disappear after the A object is called. So, relative to A, the relationship between B and A is composition. B is created when A is created, and disappears when A disappears.
5.UML Diagram
5.1 Classification of UML diagrams
Structure diagram (static diagram)
: class diagram, object diagram, use case diagram, component diagram, deployment diagram, product diagram, package diagram, composite structure diagram.Behavior diagram (dynamic diagram)
: interaction diagram, state diagram, activity diagram.Interaction diagram
: sequence diagram (sequence diagram/sequence diagram), communication diagram (collaboration diagram), timing diagram, interaction overview diagram
5.2 Structure diagram (static diagram)
1) Class Diagram
Describe classes, their properties, and the relationships between classes.
A class diagram can only have a class name, and can only have methods without attributes, but it cannot have only attributes without methods.
2) Object graph
Objects are instances of classes, and an object diagram describes a snapshot of each object in the system at a point in time.
Object diagrams and class diagrams look very similar. In fact, except for adding some “object”-specific attributes to the model representing the class, the meanings of other elements are basically the same.
Object name
: Since an object is an instance of a class, the format of its name is “object: class name”. These two parts are optional, but if the class name is included, it must be Add “:”, in addition, in order to distinguish it from the class name, you must also add an underscore.Attribute
: Since the object is a specific thing, all attribute values have been determined, so its value is usually listed after the attribute.
3) Component diagram
Describe the structure and connections of components. In layman’s terms, a component is a modular element that hides its internal implementation and provides a set of interfaces externally.
4) Deployment diagram
Describe the deployment on each node.
5) Product picture
Describes the physical structure of the system
6) Package diagram
Group transactions that are semantically closely related. In UML, a package is represented by a labeled folder symbol, which can indicate only the package name or the contents of the package.
7) Composite structure diagram
Displays the internal structure of structured classes.
5.3 Behavior diagram (dynamic diagram)
1) Interaction diagram
1.1) Sequence diagram (sequence diagram/sequence diagram)
Describe the interactions between objects, with an emphasis on chronological order.
1.2) Communication diagram (collaboration diagram)
Describes the interaction between objects, with an emphasis on connections. Communication diagrams and sequence diagrams have the same semantics but different concerns and can be converted to each other.
1.3) Timing diagram
To describe the interaction between objects, the key point is to give the specific time when the message passes through different objects.
1.4) Interaction overview map
It is a hybrid of sequence diagram and activity diagram.
2) Use case diagram
Describe use cases, actors and their relationships.
3) Activity diagram
Describe procedural behavior versus parallel behavior.
4) State diagram
Describes transitions in the state of an object.
After tidying up, it’s over and sprinkle flowers~
Reference address:
1. Master 14 kinds of UML diagrams, clear diagrams, https://blog.csdn.net/qq_35423190/article/details/125069834
2. The difference between java combination and aggregation, https://blog.csdn.net/heardreamperson/article/details/120484327