UML-class diagrams and object diagrams

Table of contents

Class diagram overview:

1. Category:

2. Attributes:

3. Class representation:

4. Five methods:

Class diagram relationship:

1. Association

2. Aggregation

3. Combination

4. Dependence

5. Generalization

6. Implementation

Object graph overview:

1. The object graph contains elements:

2. What is an object?

3. The state of the object can be changed:

4. Object behavior

5.Object identification:

The difference between classes and objects:


Class diagram overview:

Class diagrams: used to define classes in the system, including describing the internal structure of classes and the relationships between classes. Class diagrams are mainly used to describe the static structure of the system.

What is a class? A class is a group of objects with the same set of data.

1. Category:

2. Attributes:

3. Class representation:

4. Five methods:

Class diagram relationship:

1. Association

·General association

 ·Associated name

Apply to associated modifications

1) Name (Association name): used to describe the nature of the relationship

2) Role: When a class is at one end of a relationship, the class plays a specific role in the relationship; the role is the responsibility of the class near one end of the relationship to the class at the other end.

3)Multiplicity: The multiplicity of an associated role indicates how many interconnected objects there are in an associated instance.

Related examples

association

The connection (Link) between two objects can itself have its own properties and behaviors. If the connection is regarded as an instance of a class, the class is called an association class.

Self-association: An object is connected (link) to another object of the same type, that is, a class can be associated with itself

2. Aggregation

 -"whole/part"

   -Hollow rhombus

3. Combination


4. Dependence

Dependency is a usage relationship that indicates that changes in one specification may affect another thing that uses it. But the opposite is not necessarily true

5. Generalization

  Generalization relationship inheritance relationship: refers to a class (subclass, subinterface) inherits (extends) the functions of another class (parent class, parent interface), and can add some additional functions of its own. Inheritance is a class or interface The most common relationships with interfaces;

Inheritance is divided into: single inheritance and multiple inheritance

Single inheritance:

Multiple inheritance:

6. Implementation

Implementation is a semantic relationship between classifiers in which one classifier describes another classifier that guarantees an implementation contract.

 

Object graph overview:

     Object diagrams: Object diagrams are the relationships between various objects in a class diagram, describing the static structure of a system at a specific moment, while class diagrams describe all possible situations.

1.  The object diagram contains elements:

     -object
     -connection
     -package

2. What is an object?

3. The state of the object can be changed:

ID, name, etc.

4. Object behavior

·Behavior reflects how an object will respond to other objects

Xiao Ming called Xiao Liang, who was moving bricks, to come find him.

5.Object identification:

Figure 1. Saving money
Figure 2. Listening to language
Figure 3. Reading a book
Figure 4. Turning on the light
Figure 5. Watering flowers

The difference between classes and objects:

Guess you like

Origin blog.csdn.net/weixin_59272777/article/details/132214212