Original: UML class diagram Knowledge collation
UML Class Diagram
UML, advanced necessary professional skills, can not understand the UML will not understand those excellent information.
Here's a simple arrangement
Relationship generalization relationship between classes (generalization)
- Generalization (generalize): a line represented by a hollow arrow
- Implementation (realize): A dashed line with a hollow arrow indicates
Generalization in Java is represented as inheritance (extends), is-a
the relationship between
The implementation is represented as an implements
interface in Android, or an extends
abstract class
Dependency relationship (dependency)
Represented by a dashed line with an arrowhead; arrow pointing to call relationship
In a nutshell, Class A uses class B to say that a relies on B
A dependency is a temporary contingent relationship that usually occurs during operation and changes with the runtime, and dependencies can change.
Performance in code: such as the method's entry, the parameters of the construction method
Association Relationship (Association)
Use a straight line to indicate
It describes the structural relationships between objects of different classes, and represents a strong dependency between two classes, or the semantic level of a class and an interface.
Performance in Code: association objects are usually implemented as member variables
Aggregation Relationship (aggregation)
A line representation with a hollow diamond arrow
The aggregation relationship is a special case of the association relationship, it is used to represent the relationship between the entity objects, representing the whole part of the semantics; has-a
For example, a department consists of multiple employees;
Unlike the combinatorial relationship, the whole and the parts are not strongly dependent, the whole and the parts are separable, even if the whole does not exist, the parts still exist;
For example, departments are withdrawn, people do not disappear, they still exist
Composition relationship (composition)
Line with a solid diamond-shaped arrow
A composite relationship is a special aggregation relationship that is strongly dependent, a contains-a
relationship that is stronger than aggregation, also known as strong aggregation, and if the whole does not exist, then the part does not exist.
Watch out.
- Aggregation and combination are all related.
- Relationship Strength: Combination > Aggregation > Association > dependencies
Methods and properties of the class
A class can have multiple methods and properties
How properties are expressed: visibility name: Type [= default value]
How the method is expressed: Visibility name (parameter list) [: return type]
Visibility of:
+
Public
-
Private
#
Protected
~
Package
In addition: Italic representation in UML diagrams is abstract
Example
Interpretation:
ViewGroup
is a View
, is also a ViewParent
, depends on MotionEvent
(in onTouch(MotionEvent)
such a way)
Interpretation:
The employee is associated with the work number, the employee aggregates into the department, the department composes the company.
The department disbanded the employees still exist (so it is aggregated), and the company closed, the department does not exist (so is composed).
"Reprint" UML Class diagram Knowledge collation