Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the concept of UML class diagram and object diagram

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "what is the concept of UML class diagram and object diagram". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope this article "what is the concept of UML class diagram and object diagram" can help you solve the problem.

This paper focuses on the concept of UML class diagram and object diagram. UML class diagram (Class Diagram) is a diagram that describes classes, interfaces, cooperation and the relationship between them, which is used to show the static structure of each class in the system, while object diagram (Object Diagram) describes the state of each object participating in the interaction at a certain time in the process of interaction.

The concept of UML Class Diagram

I. Overview

UML class diagram (Class Diagram) is a diagram that describes classes, interfaces, collaboration and the relationship between them, and is used to show the static structure of each class in the system. UML class diagram is the basis of defining other diagrams. On the basis of UML class diagrams, we can use state diagrams, collaboration diagrams, component diagrams and configuration diagrams to further describe other aspects of the system.

The UML class diagram consists of seven elements: Class, Interface, collaboration, Dependency, Generalization, Association, and Realization.

II. Class

Class defines a set of objects with state and behavior. Where attributes and associations are used to describe the state. Attributes are usually represented by unidentified data values, such as numbers and strings. Associations are represented by relationships between identifiable objects. The behavior is described by the operation, and the method is the implementation of the operation. The lifetime of an object is described by a state machine attached to the class.

1. Name: the name of the class is a necessary component in each class.

2. Attribute (Attribute)

(1) visibility: the visibility of attributes in a class mainly includes public, Private, and Protected. In UML, public types are expressed as "+", private types as "-", and protected types as "#". There is no default visibility in UML's class, and if no symbol is displayed, the visibility of the attribute is not defined.

(2) attribute name: according to the UML convention, the word attribute name is lowercase. If the attribute name contains more than one word, the words should be merged, and the first letters of all words except * words should be capitalized.

(3) attribute string. The attribute string is used to specify other information about the attribute, such as that a property should be *. Any rule that you want to add to the attribute definition string value but there is no suitable place to add it can be placed in the property string.

(4) Class attribute. A property can also be defined as a generic property, which means that this property is shared by all objects of the class. In the UML class diagram, the class attribute has an underscore.

3. Operation. The operation of a class is an abstraction of the transactions that can be done by the objects of the class, which is equivalent to the implementation of a service.

4. Responsibilities: in the area below the operation section, you can be used to describe the responsibilities of the class. A duty is a contract or obligation of a class or other element. The responsibility of the class is to free-form text, write a phrase, a sentence, etc. In UML, list responsibilities in the separator at the bottom of the UML class diagram.

5. Restraint. The responsibility of a class is an informal way to eliminate ambiguity, and the formal way is to use constraints. The constraint specifies one or more rules to be satisfied by the class. In UML, a constraint is free text enclosed in curly braces.

III. Interface

The interface contains actions but no attributes, and it has no visible association to the outside world.

IV. The relationship between classes

There are four most common relationships between classes: dependency relationship, generalization relationship, management relationship, and implementation relationship.

UML object graph

I. Overview

UML object graph (Object Diagram) describes the state of each object participating in the interaction at a certain time in the process of interaction. An object diagram can be seen as an instance of a UML class diagram at some point in time.

In UML, object diagrams use the same symbols and relationships as UML class diagrams, because objects are instances of classes. The following figure shows the model of the object graph. The node can be an object or a class, and the connection represents the relationship between the objects:

2. The difference between UML class diagram and object diagram.

This is the end of the introduction to "what is the concept of UML class diagram and object diagram". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report