当前位置:网站首页>Do not understand UML class diagram? Take a look at this edition of rural love class diagram, a learn!
Do not understand UML class diagram? Take a look at this edition of rural love class diagram, a learn!
2020-11-06 01:17:34 【Bugstack wormhole stack】
author : Little brother Fu
Blog :https://bugstack.cn
precipitation 、 Share 、 grow up , Let yourself and others have something to gain !
One 、 Experience of yard
There's a word called involution serious !
The first time I heard this word was a little friend in my article HashMap Source code analysis article under the message :“ Brother , This is called involution !”. This article explains in depth the perturbation function 、 Load factor and related mathematical methods to verify the results , Those who are interested can jump over and read .《HashMap Core knowledge , Disturbance function 、 Load factor 、 Split the expanded list , Deep learning 》
What is involution , At first glance, the word is a bit new . Actually, involution comes from words involution
, It can also be called “ Over densification ”. This explains , such as ;
- 100 Personal access to the bathroom is 3 Pit , There's no fair distribution , That's who will wear underpants first
- 100 individual 700 Score more than , Just 30% One place can go to Qingbei .3 More than ten thousand 600 Among the candidates with a score above , Many people may even 211 Can't even get on .
- Road congestion , Don't let everyone drive , We can only wait for a long time .
These can be explained by the serious problem of involution caused by over densification , But the good thing is that these are constantly optimized .
Programmers also have inner volumes ?!
In fact, most of the time we talk about programmer involution , It's about interviewing to build rockets , It's getting harder and harder to find a job .
In fact, in a way , I personally don't agree that programmers have internal volumes . In terms of the whole industry , Programmer's employment and salary are good . Some people think that the interview still needs to brush the questions 、 Learn the source code 、 Look at the frame 、 Understand Architecture and so on , But these should not be your career path as a programmer , Must be a breakthrough ?
Maybe everyone will feel like they are in a bottleneck period at some time , Doing repetitive things 、 Code it CRUD The logic of 、 No access to core technologies, etc , I feel like a baboon soon . It seems that you can only use the word "Involution" to balance your mind , Ask yourself , Have you ever devoted yourself to learning and growing up ? Do you have a plan to break through your own bottleneck ? If not, it's not called involution !
Two 、 Conference Room
Thank you plane , Notes
, A week's flight back to work from vacation , The team leader arranged a project growth sharing .
Group leader : The plane , In the projects you share , The core module should be explained to you clearly . This one is quite technical !
Thank you plane : Mm-hmm , I'm also thinking about how to make people understand .
Group leader : It's better to use some tools , Logic the code 、 Functional process , Express it in the form of a graph .
Thank you plane : I can draw the flow chart , But the core function class here , I don't know how to do it yet .
Group leader : Cough , use UML Class diagram wow , Show the core class .
Thank you plane :…, I didn't draw , Did I roll it in ?
Group leader : shame on you ! When I draw some information , To teach you !
3、 ... and 、 Study on the class diagram of rural love
UML(Unified Modeling Language), It is a modeling tool for object-oriented design , The core of modeling is model , A model is a simplification of reality 、 Real abstraction .
stay UML in , All descriptions include : Business 、 Relationship 、 The three parts of the diagram are composed of , The following figure shows the relationship of all components .
Next , Let's focus on UML Class diagram relationships in , In the rural love characters .
1. Class diagram model
UML Class diagram (Class Diagrams), Is the most frequently used UML One of the pictures , A class diagram can represent a class 、 Interfaces and the collaboration between them . Interfaces 、 class 、 attribute 、 Method , It can be expressed as follows .
2. Inheritance relationships
Code
public class Xie Guangkun {
private String Seniority ;
public void Be a demon (){}
}
public class Xie Yongqiang extends Xie Guangkun {
}
public class Thank you plane extends Xie Guangkun {
}
Class diagram
- function : Inheritance relationships
- Concept : Inherit (Generaliztion) It's also called generalization , Used to indicate that the child class inherits all the functions of the parent class .
- scene : Xie Guangkun's demon making skills , Xie Yongqiang and Xie aircraft inherited . Thank you for inheriting it better , Better at .
3. Realization relationship
Code
public interface Dance {
void movements in martial arts or traditional opera ();
}
public class Lennon implements Dance {
private String Here's the name ;
public void movements in martial arts or traditional opera () {
}
}
public class Zhao si implements Dance {
private String Here's the name ;
public void movements in martial arts or traditional opera () {
}
}
Class diagram
- function : Realization relationship
- Concept : Interface 、 Methods of abstract class declaration , Implemented by a class (Realiztion) Its function .
- scene : In a dance competition between Zhao Si and Liu Neng , Zhao Si's fancy walk , Liu Neng was knocked down by Liu Neng .
4. synthetic relation
Code
public class A marriage certificate {
private Zhao Yutian Man ;
private Liu Ying Woman ;
public void set Man ( Zhao Yutian Man ) {
this. Man = Man ;
}
public void set Woman ( Liu Ying Woman ) {
this. Woman = Woman ;
}
}
public class Zhao Yutian {
private int Age ;
private String Gender ;
}
public class Liu Ying {
private int Age ;
private int Gender ;
}
Class diagram
- function : synthetic relation
- Concept : Combine (Combination) Relations represent the relationship between the whole and the parts of a class , The whole is dependent on the part .
- scene : The marriage certificate of Zhao Yutian and Liu Ying , Be short of one cannot .
5. Aggregate relationship
Code
public class mountain villa {
private Song Xiaofeng Xiaofeng ;
private Li Baoku Treasury ;
public void Medicine room ( Li Baoku Treasury ) {
this. Treasury = Treasury ;
}
public void Security department ( Song Xiaofeng Xiaofeng ) {
this. Xiaofeng = Xiaofeng ;
}
}
public class Li Baoku {
private String occupation ;
}
public class Song Xiaofeng {
private String occupation ;
}
Class diagram
- function : Aggregate relationship
- Concept : polymerization (Aggregate) Relationship , It is also used to represent the whole and part of an object , But the member object can exist independently from the whole object .
- scene : There is Li Baoku in the mountain villa 、 There is song Xiaofeng in the security department . But Li Baoku and song Xiaofeng are just one of them , You can leave the villa .
6. Connections
Code
public class Tofu factory {
private Wang Xiaomeng staff ;
public void Add employees ( Wang Xiaomeng Xiao Meng ){
this. staff = Xiao Meng ;
}
}
public class Wang Xiaomeng {
private Tofu factory Enterprises ;
public void Add enterprise ( Tofu factory Tofu factory ){
this. Enterprises = Tofu factory ;
}
}
Class diagram
- function : Connections
- Concept : relation (Association) Relationship , Is a common relationship between classes , Represents the relationship between one class of objects and another . Combine 、 Aggregation also belongs to this relationship , But the connection is weaker .
- scene : There is Wang Xiaomeng in the tofu factory , But it's not just Wang Xiaomeng in the tofu factory , And Wang Laoqi . Even if Xiao Meng is not here , The tofu factory can also operate normally . And Wang Xiaomeng has his own other enterprises , So it's a kind of relationship .
7. Dependency relationship
Code
public class attract investment {
public void China merchants ( Wang Dana Take it ){
}
}
public class Wang Dana {
private String resources ;
}
Class diagram
- function : Dependency relationship
- Concept : rely on (Dependency) Relationship when it means that one transaction needs to use another , You can use dependencies .
- scene : Wang Dana is needed to attract investment , But it's not just this big shot . Wang Dana can't come , Maybe there's Li Dana 、 Zhang Dana .
Four 、 Zhao Jiaban panoramic class diagram
Sum up , this 6 In a relationship , Combine 、 polymerization 、 The associated code structure is similar to , It can be understood from the strength of dependence . The order of strength and weakness is : Inherit > Realization > Combine > polymerization > relation > rely on .
In order to express more clearly UML Class relation , Let's draw these into a whole picture , as follows ;
5、 ... and 、 summary
- Some people say , If we communicate very friendly with aliens . Then there will be some communication between the two planets , For example, ask , Hello , How tall you are on earth ? The earth says 1.75 rice . Aliens are dizzy , What's the unit of meter ? In this way, we can only choose the standard of two planets to define , such as :1 Rice is light in a vacuum 1/299792458 The distance in seconds .
- In fact, program development is also like this , In order to reduce the communication cost of understanding new knowledge content , Some communication standards need to be defined , such as UML Class diagram . So we need to learn these standard instrumental languages , To reduce communication costs , Improve work efficiency .
- UML Class diagrams are also the most commonly used drawings , It's also very easy to master . In order to be able to lay their knowledge more perfect , More solid mastery of the technology stack , Also in order to break through the bottleneck of each stage . That requires constant learning , Keep accumulating , Find a chance to break .
6、 ... and 、 Series recommendation
- Is the grass , You're poisoning the code !
- A code review , Almost couldn't pass the probation period !
- Why programmers are keen on building wheels , Promotion and raise ?
- Most popular in the whole network 10 Million downloads ,《 Relearning Java Design patterns 》(22 Real development scenarios )
- Face to face manual ( Get on the fastest car , Take the most expensive offer)

( Please indicate the author and source of this article WeChat official account :bugstack Wormhole stack | author : Little brother Fu )
版权声明
本文为[Bugstack wormhole stack]所创,转载请带上原文链接,感谢
边栏推荐
- C++ 数字、string和char*的转换
- C++学习——centos7上部署C++开发环境
- C++学习——一步步学会写Makefile
- C++学习——临时对象的产生与优化
- C++学习——对象的引用的用法
- C++编程经验(6):使用C++风格的类型转换
- Won the CKA + CKS certificate with the highest gold content in kubernetes in 31 days!
- C + + number, string and char * conversion
- C + + Learning -- capacity() and resize() in C + +
- C + + Learning -- about code performance optimization
猜你喜欢
-
C + + programming experience (6): using C + + style type conversion
-
Latest party and government work report ppt - Park ppt
-
在线身份证号码提取生日工具
-
Online ID number extraction birthday tool
-
️野指针?悬空指针?️ 一文带你搞懂!
-
Field pointer? Dangling pointer? This article will help you understand!
-
HCNA Routing&Switching之GVRP
-
GVRP of hcna Routing & Switching
-
Seq2Seq实现闲聊机器人
-
【闲聊机器人】seq2seq模型的原理
随机推荐
- LeetCode 91. 解码方法
- Seq2seq implements chat robot
- [chat robot] principle of seq2seq model
- Leetcode 91. Decoding method
- HCNA Routing&Switching之GVRP
- GVRP of hcna Routing & Switching
- HDU7016 Random Walk 2
- [Code+#1]Yazid 的新生舞会
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- HDU7016 Random Walk 2
- [code + 1] Yazid's freshman ball
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- Qt Creator 自动补齐变慢的解决
- HALCON 20.11:如何处理标定助手品质问题
- HALCON 20.11:标定助手使用注意事项
- Solution of QT creator's automatic replenishment slowing down
- Halcon 20.11: how to deal with the quality problem of calibration assistant
- Halcon 20.11: precautions for use of calibration assistant
- “十大科学技术问题”揭晓!|青年科学家50²论坛
- "Top ten scientific and technological issues" announced| Young scientists 50 ² forum
- 求反转链表
- Reverse linked list
- js的数据类型
- JS data type
- 记一次文件读写遇到的bug
- Remember the bug encountered in reading and writing a file
- 单例模式
- Singleton mode
- 在这个 N 多编程语言争霸的世界,C++ 究竟还有没有未来?
- In this world of N programming languages, is there a future for C + +?
- es6模板字符
- js Promise
- js 数组方法 回顾
- ES6 template characters
- js Promise
- JS array method review
- 【Golang】️走进 Go 语言️ 第一课 Hello World
- [golang] go into go language lesson 1 Hello World