First look at the following class diagram, including the basic graphical method of UML class diagram.
? 1, class representation
? 2. Representation of interfaces
3. Inheritance relationship
4. Implement the interface
5. Relationship
6. Aggregation relationship
7, comprehensive (combination) relationship
8. Dependence
First look at the following class diagram, including the basic graphical method of UML class diagram.
First look at the' animal' rectangular box, which represents a class. ? The class diagram is divided into three layers. The first layer shows the class name. If it is an abstract class, it is displayed in italics. The second layer is the characteristics of the class, usually fields and attributes. The third layer is the operation of a class, usually a method or behavior. Notice the symbol in front,'+'? Means open,? ' -'? Means private, "#"? Means protected. "
Then pay attention? Feifei' represents an interface diagram, which differs from the class diagram mainly in that there is an "interface" display at the top. The first line is the interface name and the second line is the interface method. There is also a representation of interface, commonly known as lollipop, which means that Donald Duck has realized the interface of "talking person".
Inheritance relationship: represented by hollow triangle+solid line.
Implementation interface: represented by hollow triangle+dotted line.
Penguins need to know about climate change. Association can be used when one class "knows" another class. This relationship is indicated by a solid arrow.
(Penguins have an object with the attribute "climate")?
Let's look at goose again. Goose is a social animal, and every goose belongs to a group. A flock of geese can have many. So there's an aggregation between them? Relationship. Aggregation represents a weak "ownership" relationship, which means that object A can contain object B, but object B is not a part of object A ... Does the aggregation relationship use hollow diamond+solid arrow? To show. "
Composition (also translated as' combination') is a strong' belonging' relationship, which embodies the strict relationship between parts and the whole, and the life cycle of parts and the whole is the same [DPE]. Here, a bird and its wings are a synthetic relationship, because they are parts and whole, and the life cycle of wings and birds is the same. The composite relationship is represented by a solid diamond+a solid arrow. In addition, you will notice that there is a number'1'at both ends of the connecting line of the composite relationship? What about the number "2"? This is called radix. There can be several examples of classes at this end. Obviously, a bird should have two wings. If a class may have countless instances, it is represented by' n'. Association relations and aggregation relations can also have cardinality.
Several characteristics of animals, such as metabolism, can reproduce. Animals need oxygen, water and food to be alive. In other words, animals depend on oxygen and water. There is a dependency between them, which is indicated by dotted arrows.