1167 views|3 replies

291

Posts

5

Resources
The OP
 

UML Introduction and Class Diagram Detailed Explanation [Copy link]

When developing embedded software, for more complex projects, before writing code, we usually conduct requirements analysis and software function design first. The more common way to achieve this is to use UML modeling.

This article will introduce some commonly used UML diagram knowledge points and drawing examples in embedded development.

This article first introduces the class diagram in UML.

1 Introduction to UML

1.1 What is UML

UML, the full name of Unified Model Language, is a standard language composed of a set of diagrams for describing, visualizing and documenting products of object-oriented systems. UML represents a set of best engineering practices that have proven to be successful in modeling large and complex systems. UML is a very important part of developing object-oriented software and the software development process. In embedded system design, using UML for modeling and documenting can usually achieve twice the result with half the effort.

1.2 Origin and Development of UML

The emergence of UML originated from the combination and unification of the methods of three object-oriented masters:

  • Booch Method by Booch

  • OOSE, Martin/Odell method created by Jacobson

  • OMT, Shlaer/Mellor method created by Rumbaugh

Although these methods are different, their common concepts are very similar. The three were combined and the first version called "Unified Method" was launched in October 1995: Unified Method 0.8.

Later, the UML 1.0 version named "Unified Modeling Language" was submitted to the OMG (Object Management Group). By the end of 1997, the OMG

UML1.1 was officially adopted as the standard modeling language based on object-oriented technology. UML1.1 and UML 2.0 (released in 2005) are two milestone versions in the history of UML.

1.3 Various diagrams in UML

UML has many different types of diagrams, including:

  • Static diagrams: use case diagrams, class diagrams, package diagrams

  • Dynamic diagrams: activity diagrams, state diagrams, sequence diagrams, collaboration diagrams

These different diagrams can provide a description of the system from different perspectives. In addition to programmers, large-scale software development processes also include product, design, and testing personnel. These people have different concerns about different aspects of the system, so different levels of detail need to be considered during modeling.

In this article, let's first introduce the basic knowledge of UML class diagram.

2 UML class diagram example

2.1 Visio design UML class diagram

Create a new Visio file. When you open it, you will be prompted to create a certain type of diagram. Here, select "Software and Database -> UML Class Diagram"

After clicking OK, you will enter the UML class diagram editing interface. On the left, you can see the basic elements for UML class diagram editing:

Drag these elements to the editing and decoding panel on the right, and you can see the basic structure of these elements:

2.2 A UML class diagram example

Below is an example of a UML class diagram:

  • Animal is an abstract class. One of its subclasses is Bird. Bird can be divided into geese, ducks, penguins, and a subclass of Duck is Donald Duck. These are inheritance relationships.

  • Animals rely on oxygen and water, which is a dependent relationship.

  • Wings are part of a bird, and wings cannot exist independently. They belong to a synthetic (or combined) relationship.

  • Many geese gather together to form a flock, which is an aggregation relationship.

  • Geese can fly, which belongs to the interface (or implementation) relationship

  • Penguins 'understand' climate patterns, a correlation

3 Introduction to UML class diagram elements

The following is a detailed introduction to the various elements in the UML class diagram.

3.1 Graph

The diagrams in the UML class diagram mainly include class diagrams and interface diagrams .

3.1.1 Class Diagram

The class diagram is the main element in the UML class diagram. The structure of the class diagram consists of 3 lines:

  • Line 1: is the name of the class

  • Line 1: It is the attribute of the class, that is, the various member variables of the class

  • Line 1: is the class method, that is, various member functions of the class

Main: If the class name is italic, it means it is an abstract class, such as the animal here

For symbols before properties and methods:

  • +: common type, public

  • -: private type, private

  • #: protection type, protect

3.1.2 Interface Diagram

The interface diagram is similar to the class diagram. The biggest difference from the class diagram is that the top is marked with "<<interface>>" to indicate that this is an interface diagram. The interface diagram has only two lines:

  • Line 1: is the name of the interface

  • Line 1: is the method of the interface, that is, the function implementation

Note: There is another "lollipop" representation of the interface diagram. The interface name is next to the circle, and the implementation of the interface method is implemented in the class.

3.2 Relationship

The connections between graphs are connected through various relationship lines, including: interface relationships, dependency relationships, inheritance relationships, composition relationships, aggregation relationships, and association relationships .

3.2.1 Interface relationship (implementation relationship)

Interface relationship, also known as implementation relationship, is represented by a triangle arrow + dotted line , with the arrow pointing to the interface , indicating that the class is the implementation of all features and behaviors of the interface

3.2.2 Dependencies

Dependency describes a usage relationship, that is, the implementation of one class requires the assistance of another class. It is represented by a normal arrow + a dotted line , with the normal arrow pointing to the user.

3.2.3 Inheritance relationship (generalization relationship)

Inheritance relationship, also known as generalization relationship, is represented by a triangle arrow + solid line , with the arrow pointing to the parent class , indicating that the child class inherits all the characteristics and behaviors of the parent class.

3.2.4 Synthesis relationship (combination relationship)

A composite relationship, also called a combination relationship, describes a relationship between a whole and a part, where the part cannot exist independently of the whole. It is represented by a solid diamond + a solid line , with the solid diamond pointing to the whole.

3.2.5 Aggregation

Aggregation describes the relationship between the whole and the parts, and is represented by a hollow diamond + solid line , with the hollow diamond pointing to the whole.

3.2.6 Relationship

An association relationship describes the structural relationship between objects of different types and is represented by a normal arrow + a solid line , with the arrow pointing to the associated object .

A bidirectional association can have two arrows or no arrows. A unidirectional association has one arrow.

4 Conclusion

This article introduces the basics of UML class diagrams, including 2 and 6 relationships, and demonstrates how to draw a UML class diagram using Visio software.

This post is from Programming Basics

Latest reply

Thanks for sharing!   Details Published on 2023-6-15 14:21
 

6580

Posts

0

Resources
2
 

The basic knowledge of UML diagrams and drawing methods really needs to be popularized.

This post is from Programming Basics

Comments

Yes, UML is quite practical for programming, but there are not many books that specifically teach this knowledge.  Details Published on 2023-6-12 22:07
 
 
 

291

Posts

5

Resources
3
 
Jacktang posted on 2023-6-12 07:26 The basic knowledge of the knowledge points and drawing methods of UML diagrams really needs to be popularized

Yes, UML is quite practical for programming, but there are not many books that specifically teach this knowledge.

This post is from Programming Basics
 
 
 

6067

Posts

4

Resources
4
 

Thanks for sharing!

This post is from Programming Basics
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
[Share] Some good technical websites

Find a post and share it with other technology enthusiasts. Electronic Project Expo Network:http://www.51project.com.cn/ ...

A DIY DC to DC negative pressure module

This module is made of integrated block LTC3863. The specifications and size are very small, only the size of one RMB yu ...

Which wireless method is the fastest for transferring files between mobile phones and computers?

When the mobile phone and computer are connected by wire, file transfer is the fastest. You can directly move files in t ...

Motor control basics - timer basics and PWM output principles

This post was last edited by DDZZ669 on 2021-2-20 11:45 In the development of single-chip microcomputers, the control of ...

[Analysis of College Student Electronics Contest Topic] —— 2021 Topic A "Signal Distortion Measurement Device"

1. Mission Design and manufacture a signal distortion measurement device to collect and analyze the periodic signal (her ...

36 "Ten Thousand Miles" Raspberry Pi Car——ROS Learning (VSCode to Implement Hello World)

It is very convenient to run ROS projects in VSCode. In this section, we use ROS to write and run the "Hello world" pro ...

[DIY] Logitech K260 keyboard set modified lithium battery power supply and added working instructions

This post was last edited by dcexpert on 2023-1-24 18:22 During the Chinese New Year holiday, I don't have much to do, ...

[The 3rd Xuantie Cup RISC-V Application Innovation Competition] Huashan School Development Environment Configuration

This post was last edited by eew_dy9f48 on 2023-10-4 15:25 This week we will try to configure the required development ...

Layout of electrostatic protection devices on high-voltage power ICs

Introduction: nLDMOS has been widely used in power management chips, LED/LCD drivers, portable products, automotive elec ...

"Rust in Action" BrainRust 02-Rust that doesn't emit smoke when running

This post was last edited by nemon on 2024-8-8 18:20 Last time ( https://en.eeworld.com/bbs/thread-1289538-1-1.html ) I ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list