All the dry stuff you need, it’s all here

The most comprehensive UML tutorial

The words in the front

For the record, part of this blog is from Wikipedia and Calvinsily’s UML tutorial. This blog does not involve advanced technology. It aims to share related technology and save time cost of learning for most friends.

UML overview

What is UML?
  • UML is a standard language for describing, visualizing, and documenting the products of object-oriented development systems.

  • As a model language, UML enables developers to focus on building the model and structure of the product, rather than choosing what programming language and algorithm to implement;

  • UML is different from other common programming languages, such as C + +, Java, COBOL, etc., it is a drawing language, used to do software blueprint;

  • UML is not a programming language, but tools can be used to generate code in various languages using UML diagrams;

UML core

At the heart of UML are diagrams, which can be roughly categorized as structure diagrams and behavior diagrams.

  • Structure diagram is composed of static diagram, such as class diagram, object diagram and other static diagram;

  • Behavior diagrams are composed of dynamic diagrams such as sequence diagrams and collaboration diagrams;

The static and dynamic properties of a system are visualized through the use of these diagrams.

UML class diagram:

Class diagrams are the most popular UML diagrams in object-oriented societies. It describes the objects in a system and their relationships, allowing us to have a complete understanding of the system before writing the correct code. A single class diagram describes a specific aspect of the system, and the collection class diagram represents the entire system. Basically, a class diagram represents a static view of the system.

Class diagrams are the only language UML diagrams that map directly to object-oriented objects. As a result, it is widely used by the developer community.

UML Object Diagrams:

An object diagram is an instance of a class diagram. Therefore, the basic elements of a class of graphs are similar. An object graph is made up of objects and links. At a particular moment, it captures an instance of that system. Object diagrams are used for prototyping, reverse engineering, and actual scene modeling.

UML use case Diagram:

Use case diagrams capture the dynamic nature of the system by describing the functions of the system from the user’s point of view and identifying the operators of each function. A high-level design use case diagram is used to capture the requirements of the system, so it represents the function and flow of the system. Although the forward and reverse engineering of the use case diagram is not a good choice, they still model it in a slightly different way.

UML interaction Diagram:

Interaction diagrams to capture the dynamic properties of the system. Interaction diagram includes sequence diagram and collaboration diagram. Sequence diagram shows the dynamic cooperation relationship between objects. It emphasizes the order of sending messages between objects and shows the interaction between objects. Collaboration diagrams describe the collaboration between objects. Collaboration diagrams, similar to sequence diagrams, show the dynamic collaboration between objects.

UML state diagram:

A state diagram is a five-diagram used to simulate the dynamic nature of a system. These diagrams are used to simulate the entire life cycle of an object. The state of an object is defined as the condition in which the object resides, the specific time in which the object moves against other states, and when certain events occur. State diagrams are also used for forward and reverse engineering. State diagrams focus on the process of moving from one state to another, with the participation of external events.

UML activity Diagram:

The activity diagram describes the activities to be performed to meet the requirements of the use case and the constraints between the activities, facilitating the identification of parallel activities. Activity diagram is a special kind of state diagram, which is particularly important for the functional modeling of the system, emphasizing the control flow between objects.

These are the related concepts of UML. In fact, it is simple to say that drawing, as for how to draw, let’s learn together

I will not and will not be able to cover the various elements of UML here. I will only cover the relationships between the classes in the class diagram; If you can understand the meaning of the lines and arrows between classes in the class diagram, you will be able to cope with daily work and communication.

Class diagrams are object – oriented modeling. They are commonly used in systematic classification applications of conceptual modelling and can translate model modeling into code.

  • UML provides mechanisms to represent members of a class, such as attributes and methods, to their other information.
  • Specifying the visibility of a class member (that is, any attribute or method) has the following symbols, which must precede each member’s name:

A class has three regions

  • At the top is the class name
  • The middle section contains the attributes of the class
  • The bottom section contains the methods of the class

Let’s start with an example

Look at the following class diagram to see the relationships between classes:

  • The class diagram structure of the car is <>, indicating that the car is an abstract class.
  • It has two inherited classes: car and bike; The relationship between them is represented by a dashed line with a hollow arrow.
  • The relationship between car and SUV is also inheritance relationship, and the relationship between them is generalization relationship, which is represented by solid line with hollow arrow.
  • The relationship between the car and the engine is a combination, which is represented by a solid line with a solid arrow.
  • There is an aggregation relationship between students and classes, which is represented by solid lines with hollow arrows.
  • The relation between students and ID cards is a solid line.
  • Students need to use bicycles to go to school. It is a dependency relationship with bicycles, which is indicated by dotted lines with arrows.
Instance-level relationships
  • Generalization Generalization, or the opposite direction of inheritance, is when a class (called a parent class or a parent interface) has the common functions of another class (or some classes) (called a child class or subinterface). A subclass can be considered a special case of its parent and can add new functionality. It is represented by a solid line with a hollow triangular arrow.
  • Realization Realization refers to the Realization that a class implements the functionality of an interface (which can be multiple); In Java, such relationships are explicitly identified by the keyword implements. Represented by a dashed line with a hollow triangular arrow.
  • A Dependency can simply be interpreted as A class A using A class B, “… uses a …” The dependent object is used only as a tool and does not hold references to it. This usage relationship is contingent, temporary and very weak, but the change of type B will affect A. At the code level, class B is used as A parameter by class A in A method. It is represented by a dotted line with a dovetail arrow. Indicates that one class depends on the definition of another class; Dependencies simply describe a use-to-be relationship between classes.
  • Association Association relationships enable one class to know the properties and methods of another class. An object can hold a reference to another object for a long time, and there is no enforceable constraint on the relationship between the two objects. The two objects can be disassociated or associated at any time if they agree to do so. There is no agreement on the lifetime of the two objects. An associated object can be associated with other objects, so an association can be shared. At the code level, the associated class appears in the associated class as a class attribute, or the associated class may refer to a global variable of type associated class. There are currently five different types of associations defined. Bi-directional and Uni-directional associations are the most common.
  • An Aggregate is a special kind of association between whole and parts. It is a “weak” inclusion (“… owns a …” ), a category can exist independently without relying on an aggregate class, can have their own life cycle, and a part can belong to or be sharable for multiple whole objects. For example, ponds and ducks. Another example is the convergent relationship between the professor and the course. There are several students and books in the library. Students can exist even without libraries, and the relationship between students and libraries is aggregation. An aggregation may not involve more than two classes. The figure is represented by a hollow rhombus with a solid line.

This is the introduction of UML and its most important class diagram. I believe that you have already started UML at this time, and you may want to learn more about IT. It doesn’t matter.

The most comprehensive UML tutorial in photoshop: Thanks to Calvinsily for sharing this tutorial.

A little red heart, please! Because your encouragement is the biggest motivation for my writing!

More exciting articles please pay attention

  • Personal blog: Darryrzhong
  • The Denver nuggets
  • Jane’s book
  • SegmentFault