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

How to use UML use case diagram and class diagram

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail how to use UML use case diagrams and class diagrams. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

UML practice-use case diagrams, class diagrams:

The key to dealing with object-oriented problems is modeling. Modeling can abstract many important details in a complex world. Many modeling tools encapsulate UML (that is, UnifiedModelingLanguage ™), and the purpose of this course is to demonstrate the highlights of UML.

There are nine modeling icons in UML, namely:

Use case diagram

Class diagram

Object graph

Sequence diagram

Collaboration diagram

State diagram

Activity diagram

Component diagram

Configuration diagram

Some parts of this course contain page links to the details of these diagrams. And each part has a small problem, test your understanding of this part.

Why is UML important?

To answer this question, let's look at the construction industry. The designer designed the house. The builders used this design to build the house. The more complex the building, the more important the communication between designers and builders. Blueprints have become a required course for designers and builders in this industry. Writing software is like building a building. The more complex the system, the more important the communication between the people involved in writing and configuring the software. Over the past decade, UML has been the "architectural blueprint" between analysts, designers and programmers. Now it has become part of the software industry. UML provides a common language for analysts, designers and programmers in software design.

UML is applied to solve object-oriented problems. If you want to learn UML, you must be familiar with the fundamental principles of object-oriented problem solving-- all starting with the construction of models. A model model is the abstraction of the fundamental problem. The domain domain is the real world in which the problem lies.

The model is composed of object objects, which interacts with each other by sending messages messages to each other. Remember to think of an object as "alive". Objects have what they know (property attributes) and what they can do (behavior or action behaviorsoroperations). The value of the object's property determines its state state.

The class Classes is the "blueprint" of the object. A class encapsulates attributes (data) and behaviors (methods or functions) in a separate entity. The object is an instance of the class instances.

Use case diagram

The use case diagram Usecasediagrams in UML practice describes the impression of the system from the perspective of an external observer. Emphasize what the system is rather than how the system works.

The use case diagram is closely related to the plot. Plot scenario refers to what happens when someone interacts with the system. The following is the plot of a hospital outpatient department.

"A patient called the outpatient department to make an appointment for an annual physical checkup. The receptionist found out the nearest unbooked time in the appointment log book and wrote down the appointment record for that time."

A use case Usecase is the sum of a series of scenarios that complete a job or achieve a goal. The role actor is the person or event that initiates an event related to the job. The role simply plays the role of a person or object. The figure below is an outpatient MakeAppointment use case. The character is a patient. The link between the role and the use case is the communication contact communicationassociation (or communication communication for short)

The character is a human icon, the use case is an ellipse, and the communication is the line that connects the character to the use case.

A use case diagram is a collection of roles, use cases, and relationships between them. We have made MakeAppointment part of a diagram with four roles and four use cases. Note that a single use case can have multiple roles.

In UML practice, use case diagrams are useful in three areas:

Determine characteristics (requirements). When the system has been analyzed and designed, new use cases generate new requirements

Customer newsletter. Using use case diagrams can easily show the relationship between developers and customers.

Generate test cases. The plot of a use case may produce a batch of test cases for these scenarios.

Class diagram

In UML practice, the class diagram Classdiagram represents the system by showing the classes of the system and the relationships between them. Class diagrams are static-they show what can make a difference but don't tell you when.

The following is a class diagram of a model of a customer ordering goods from a retailer. The central class is Order. Connected to it are the Customer and Payment of the purchased goods. Payment comes in three forms: Cash,Check, or Credit. The order includes OrderDetails (lineitem), each of which is attached to an Item.

The symbol of the UML class is a box divided into three blocks: class name, attribute, and operation. The name of an abstract class, such as Payment, is italic. The relationship between classes is a connector.

There are three relationships between class diagrams in UML practice:

The association association- represents the relationship between two kinds of instances. Use association if an instance of one class must use an instance of another class to complete the work. In the figure, the association is represented by a connection between the two classes.

Aggregate aggregation- is a special relationship when a class belongs to a container. Aggregation uses a connection with a diamond that points to a class with global properties. In our diagram, Order is the container for OrderDetails.

Generalize generalization- an inheritance line that points to other classes as superclasses. The generalization relation points to the superclass with a triangle. Payment is a superclass of Cash,Check and Credit.

An association has two ends. Each trailer can have a role name rolename to illustrate the role of the association. For example, an OrderDetail instance is a project of an Order instance.

The directional navigability arrow on the association indicates the direction in which the association is passed or queried. The OrderDetail class can query his Item, but not vice versa. The arrow direction can also tell you which class has the implementation of the association; that is, OrderDetail owns Item. The association of arrows without direction is two-way.

The number at the end of the association represents the number of instances on the digital side that an instance on the other side of the association can correspond to, and the associated diversity multiplicity is expressed in this way. A variety of numbers can be a single number or a range of numbers. In the example, there is only one Customer per Order, but a Customer can have any number of Order.

The following table shows the most common examples of diversity.

Diversity meaning

0. 10 or 1 instance. N. M symbol indicates that there are n to m instances

There is no limit on the number of instance cells (including none).

1 there is only one instance

1. * at least one instance

Each class diagram includes class, association, and diversity representations. Directionality and roles are optional items to make the illustration clearer.

This is the end of this article on "how to use UML use case diagrams and class diagrams". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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