preface

In my last article, I wrote about the Builder pattern, which had several UML class diagrams.

What is UML?

UML is short for Unified Model Language, which is a standardized modeling Language composed of a set of diagrams.

Why UML?

The use of UML makes the whole software design more readable and understandable before software development, thus reducing the development risk. At the same time, it can also facilitate communication between various developers.

UML provides a very expressive modeling language that allows different people in the software development process to get the information they are interested in.

In Fundamental Object-oriented Design in UML, Page-Jones summarizes the main purposes of UML as follows:

  1. Provide users with a ready-made, expressive visual modeling language to develop and exchange meaningful models.
  2. Provide Extensibility and Specialization mechanisms for core concepts.
  3. Independent of a particular programming language and development process.
  4. Provides a formal foundation for understanding the modeling language.
  5. Encourage the development of the market for object-oriented tools.
  6. Support for higher-level development concepts such as collaboration, frameworks, patterns, and components.
  7. Integrate Best Practices.

What are UML diagrams?

  • UML diagrams are divided into structure diagrams and behavior diagrams.
  • Structure diagram is divided into class diagram, contour diagram, component diagram, composite structure diagram, object diagram, deployment diagram, package diagram.
  • Behavior diagram is divided into activity diagram, use case diagram, state machine diagram and interaction diagram.
  • Interaction diagram is divided into sequence diagram, sequence diagram, communication diagram, interaction overview diagram.

An overview of the UML diagrams

What is a class diagram?

  • Class diagrams are the core modeling tool for all object-oriented methods. Class diagrams describe the types of objects in the system and the various static relationships that exist between them.
  • 【 Purpose 】 Used to represent classes, interfaces, and static structures and relationships between them.

In class diagrams, the following relationships are common.

Generalization.

  • Generalization relationship is an inheritance relationship, indicating that a subclass inherits all the characteristics and behaviors of its parent class.
  • Arrow point a solid line with a triangular arrow pointing to the parent class.

Realization

  • 【 Implementation relation 】 is a relationship between a class and an interface, indicating that a class is the implementation of all the characteristics and behaviors of the interface.
  • Arrow Point: Dashed line with triangular arrow pointing to interface.

Association

  • A relational relationship is an ownership relationship that makes one class know the properties and methods of another class.
  • Member variables
  • Arrow Pointing A solid line with an ordinary arrow pointing to the owner. A bidirectional association can have two arrows or no arrows. A one-way association has an arrow.

I bought my own car and I can drive it whenever I want. But cars are cars and people are people, and there is no relationship between the whole and the parts.

Aggregation

  • Aggregation relation is a relation between whole and parts. And parts can exist independently of the whole. Aggregation relation is a kind of correlation relation, which is strong correlation relation. Association and aggregation are syntactically indistinguishable and must be examined for specific logical relationships.
  • Member variables
  • Arrow points to a solid line with a hollow diamond that points to the whole.

The computer has a keyboard to input information, the computer is the whole, the keyboard is part, the keyboard can also leave the computer, simply take to knock. So it’s polymerization.

Composition

  • [Combinatorial relation] is a relationship between whole and parts. However, the part cannot exist independently without the whole, and the combinatorial relation is a kind of correlation relation, which is stronger than the aggregation relation.
  • Member variables
  • Arrow pointing: Solid line with solid diamond and regular arrow, solid diamond pointing to whole.

A bird is a whole, and its wings are parts. When a bird dies, its wings cannot fly. So it’s a combination. Let’s look again at the following set of classic examples of aggregate combinatorial relationships.

A company has multiple departments, and there is a portfolio relationship between the company and the department. When the company goes bankrupt, the department no longer exists. The department and the employee are convergent, the department is cut, the employee is changed.

Dependency

  • Dependency is a usage relationship in which the implementation of one class requires the assistance of another class.
  • [Arrow Point] Dashed line with normal arrow, which points to the user.

The old driver just drives the car, it doesn’t matter who owns the car.

What is a component diagram?

  • Concept Describes the interfaces and ports provided and required by components in the system, and the relationships between them.
  • [Purpose] Used to show the dependencies between components.

The order system component relies on the customer repository and the inventory system component. The dotted arrows in the middle indicate dependencies. The other two symbols represent component connectors, one providing an interface and one requiring an interface.

What is a deployment diagram?

  • Concept Describes how software within a system is distributed on different nodes.
  • [Purpose] Indicates the mapping between hardware and software.

In a nutshell, different software is deployed on different machines.

What is an object graph?

  • An object diagram is an instance of a class diagram, which is a snapshot of the detailed state of the system at a point in time.
  • Purpose The relationship between two or more objects at a certain point in time.

Bat had a R&D department and a sales department at a certain time. The two departments had only one person, Iisheng.

What is a package diagram?

  • [Concept] Describes the structural design of the system at the package level.
  • Purpose Indicates the dependencies between packages.

  • “Use” relationship means Use dependency,Web ShoppingRely onPayment
  • The Merge relationship means to Merge,Web ShoppingmergedShopping CartHave theShopping CartThe function of the
  • The Access relationship represents private imports, such as the specified package name class name in the code
  • The Import relationship represents public imports, such as in JavaimportAfter that, it can be used directlyimportClass in the package.

What is a combinatorial structure diagram?

  • 【 Concept 】 Describes the internal structure of a “composite structure” and the relationships between them. This “composite structure” can be a part of the system, or a whole.
  • 【 Objective 】 Used to represent the logical “combinatorial structure” of a system.

The picture depicts the Car as a combination of two front wheels, two rear wheels, and an engine connected by an axle.

What is a contour diagram?

  • Outline diagrams provide a common extension mechanism for customizing UML models for specific domains and platforms.
  • 【 Objective 】 Used to construct UML models in specific domains.

Here we define a simple EJB profile diagram. Beans extend from Component. Entity Beans and Session Beans inherit from beans. Ejbs have Remote and Home interfaces, and JAR packages.

What is a use case diagram?

  • 【 Concept 】 A use case diagram is a view of a system’s functionality consisting of actors, use cases, boundaries, and the relationships among them.
  • Purpose Describes the function of the entire system.

The use case diagram contains the following three relationships:

  • The include relationship uses the symbol include. To view the list of orders, you need to log in first.
  • The extended relationship uses the symbol “extend” to add a function to export data based on the ability to query the order list
  • Generalized relationships, in which child use cases inherit all structure, behavior, and relationships from parent use cases.

What is an activity diagram?

  • 【 Concept 】 Describes the implementation process of specific business use cases.
  • 【 Objective 】 Used to represent the workflow of use case realization.

The diagram simply describes the process from start to login to view the order list, or login failure to end directly.

What is a state machine diagram?

  • 【 Concept 】 A state machine diagram models the behavior of an individual object, specifying the sequence of events that an object executes in response to different events throughout its life cycle.
  • [Purpose] Used to indicate the different states of the specified object in response to different events throughout its life cycle.

The diagram depicts the states that the gate experiences during its lifetime.

What is a sequence diagram?

  • 【 Concept 】 Sequence diagrams show how objects collaborate in terms of time series. It shows how objects interact with other objects in a particular scenario of a use case.
  • 【 Objective 】 To display dynamic collaboration between multiple objects by describing the chronological order in which messages are sent between objects.

The figure shows the sequence diagram of alipay bar code payment scenario. Where loop is a loop and Alt is a selection, the other relationships of the sequence diagram are not covered here.

What is a communication map?

  • Concept Describes the organizational relationship of the objects receiving and receiving messages, emphasizing the cooperative relationship between objects rather than the chronological order.
  • 【 Purpose 】 Used to display the relationship between different objects.

The picture shows the communication diagram of an online bookstore. The boxes and small figures represent lifelines. Messages can be transmitted between different lifelines, and the numbers before the messages can express the sequence.

What is an interaction overview diagram?

  • 【 Concept 】 An interaction overview diagram is similar to an activity diagram, but its nodes are interaction diagrams.
  • 【 Objective 】 To provide an overview of control flow.

The diagram represents an interactive overview of a scheduling system, much like the activity diagram. The SD box represents the specific interaction process, and the REF box represents the use of interaction.

What is a sequence diagram?

  • Sequence diagrams are used to show changes in the value or state of one or more elements over time. It also shows the interaction between time-controlled events and the time and deadline constraints that manage them.
  • Purpose A view used to represent changes in the state or value of an element over time.

This is a picture of alzheimer’s disease over time.

conclusion

Learning UML, we don’t have to wrestle with questions like whether aggregate relationships have arrows or not. More importantly, UML diagrams bring us drawing ideas. Let us draw UML diagrams or other diagrams so that others can better understand our design ideas.

Of course, if you know exactly which one is wrong with arrows or without arrows, please let me know in the comments.

References: [1]: Learning UML 2.0 [2]: www.uml-diagrams.org/ [3]: www.visual-paradigm.com/guide/ [4]: Sparxsystems.com/resources/t…

If the article is useful to you, please help me to give a thumbs-up, it is really important to me.