Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”

This article also participated in the “Digitalstar Project” to win a creative gift package and creative incentive money

👨🎓 author: Java Academic Conference

🏦 Storage: Github, Gitee

✏️ blogs: CSDN, Nuggets, InfoQ, Cloud + Community

💌 public account: Java Academic Party

🚫 special statement: the original is not easy, shall not be reproduced or copied without authorization, if you need to reproduce can contact xiaobian authorization.

🙏 Copyright notice: part of the text or pictures in the article come from the Internet and Baidu Encyclopedia, if there is infringement, please contact xiaobian as soon as possible. Wechat search public Java academic party contact xiaobian.

☠️ Doubt anyone but never yourself.

👋 Hello! I am your old friend Java Academic party. Today I will share with you UML diagrams and some of the most important relationships of UML class diagrams. In a few minutes, I will show you how to make UML class diagrams. In the static mechanism of UML, the class diagram is a key point, which is not only the core concern of designers, but also the core concern of implementers.

3. UML

  • UML(Unified Modeling Language) is a language tool for software system analysis and design that helps developers think and document the results of their thinking.
  • UML itself is a set of notations, like mathematical and chemical notations, used to represent relationships between elements such as classes, interfaces, implementations, generalizations, dependencies, compositions, aggregations, and so on.
  • UML can draw sequence diagrams, use case diagrams, and class diagrams.

3.1 a UML class diagram

  • Used to describe the composition of classes (objects) themselves in the system and various static relationships between classes (objects).
  • Relationships between classes: dependencies, generalization (inheritance), implementation, association, aggregation, and composition.

3.2 Class Diagram – Dependencies

  • As long as you use each other in a class, there is a dependency between them, and without each other, you can’t even compile.

Class where each other is used:

  • Class member attributes
  • Method return type
  • The type of argument received by the
  • Method

Dependencies use dotted arrows that point to the dependent

3.3 Class diagram — Generalization relationship

  • The generalization relation is actually the inheritance relation, which is the characteristic of the dependence relation.

  • Generalization is inheritance.

  • If A inherits B, we say that A and B have A generalization relationship.

Generalization uses solid line hollow arrows that point to inherited classes

3.4 Class Diagram – Implementation relationships

  • An implementation relationship is one in which class A (the implementation class) implements class B (the interface), which is A special case of dependencies.

The implementation relationship uses a dashed hollow arrow with the interface pointing to the interface

3.5 Class Diagram – Association Relationship

  • Relational relationships are actually relationships between classes, and they are special cases of dependencies.
  • Associations are navigational: bidirectional or monomial associations
  • Associations have multiplicity: one-to-many, one-to-one, many-to-one, many-to-many.

Associations use solid arrows (one-way associations) or solid lines without arrows (two-way associations) that point to the called

As can be seen from the figure above, the IDCard class is used in the Person class, but the Person class is not used in the IDCard class. At this time, it is one-way one-to-one, and there is an arrow, which points to the class to be called.

In the second one, the classes between them call each other, so there’s a two-way one-to-one relationship, and there’s no arrows.

3.6 Class Diagram – Aggregation relationship

  • The aggregation relation represents the relationship between the whole and the parts, which can be separated. Aggregate relation is a special case of association relation, so it has the navigability and multiplicity of association.

For example, the keyboard and monitor of a computer can be separated from the computer and represented by solid lines with hollow diamonds. (Hollow diamond points from part to whole)

Aggregation uses hollow diamond-shaped arrows that point to the caller

3.7 Class Diagram – Combination Relationship

  • Combination is also the relationship between whole and part, but the whole and part can not be separated. (People and brains, for example, are combinatorial.)

  • If a member variable in a class cannot be separated from the whole class, it is called a composition. For example, if the above mouse class cannot be separated from the computer, it is a combinatorial relationship. (At this point, the object is new. When the Computer class is loaded, the mouse class will also be loaded. When the Computer class disappears, the mouse class will also disappear.

  • The combination uses a diamond arrow representation of the entity that points to the caller.

Distinguishing combination from aggregation:

  • People’s bodies and people can not be split, so this is a combination of relations.
  • The person’s ID card and the person can be split, right now it is aggregation.

–💘 read the big guys can pay attention to the small make up, will always update small skills, free to share to you!! 💝 –