当前位置:网站首页>[UML] UML class diagram
[UML] UML class diagram
2022-06-30 23:44:00 【weixin_ forty-three million two hundred and twenty-four thousan】
The installation steps are :File -> Settings -> Plugins Search for PlantUML , find PlantUML integration And install .
1.UML Basic introduction
1) UML——Unified modeling language UML ( Unified modeling language ), It is a language tool for software system analysis and design , It is used to help software developers think and record the results of ideas
2) UML It is a set of rules of symbols , Just like mathematical symbols and chemical symbols , These symbols are used to describe the various elements in the software model and their relationships , Such as class 、 Interface 、 Realization 、 generalization 、 rely on 、 Combine 、 Polymerization, etc. , Like the picture on the right :

2.UML chart
draw UML The picture is similar to writing an article , They describe their thoughts to others , The key is thinking and organization ,UML Picture classification :
1) Use case diagram (use case)
2) Static structure diagram : Class diagram 、 Object graph 、 Package diagram 、 Component diagram 、 Deployment diagram
3) Dynamic behavior diagram : Interaction diagram ( Sequence diagram and collaboration diagram )、 State diagram 、 Activity diagrams
3.UML Class diagram
1) Used to describe classes in the system ( object ) Its composition and class ( object ) All kinds of static relations between .
2) Relationships between classes : rely on 、 generalization ( Inherit )、 Realization 、 relation 、 Aggregation and combination .
3) attribute / The plus and minus signs preceding the method name represent this property / Visibility of methods ,UML There are three symbols for visibility in class diagrams :
+: Express public
-: Express private
#: Express protected
The complete representation of attributes is : visibility name : type [ = The default value ]
The complete representation of a method is : visibility name ( parameter list ) [ : Return type ]
4 . Class diagram — Dependence (Dependence)
As long as the other party is used in the class , Then there is a dependency between them . If there's no one else , I can't even pass the compilation .
public class PersonServiceBean {
private PersonDao personDao;// class
public void save(Person person){}
public IDCard getIDCard(Integer personid){}
public void modify(){
Department department = new Department();
}
}
public class PersonDao{}
public class IDCard{}
public class Person{}
public class Department{}Class diagram : rely on

Summary :
1) Class uses the other side
2) If it's a member property of a class
3) If it's the return type of the method
4) Is the type of parameter the method receives
5) Method used in
5. Class diagram — Generalization off (generalization)
Generalization is actually inheritance , He's a special case of dependency
public abstract class DaoSupport{
public void save(Object entity){
}
public void delete(Object id){
}
}
public class PersonServiceBean extends Daosupport{
}Class diagram : Inherit

Summary :
1) Generalization is actually inheritance
2) If A Class inherited B class , We said A and B There is a generalization relationship
6. Class diagram — Realization relationship (Implementation)
Realizing a relationship is actually A Class implementation B Interface , He's a special case of dependency
public interface PersonService {
public void delete(Interger id);
}
public class PersonServiceBean implements PersonService {
public void delete(Interger id){}
}Class diagram : Realization

Summary :
7. Class diagram -- Connections (Association)
Association is actually the relationship between classes , It is a special case of dependency
The association is navigable : That is, two-way association or single Association .
Relationships are multiple : Such as "1"( It means that there is only one ),"0..."( Express 0 One or more ),"0,1"( Express 0 One or one ),“n,m”( Express n To m Every one can ),“m...*”( At least m individual ).
// Single one-to-one relationship
public class Person{
private IDCard card;
}
public class IDCard{}
// Two way one-on-one relationship
public class Person{
private IDCard card;
}
public class IDCard{
private Person person;
}
// Many to many relationship Class diagram : relation

Summary :
The type of the attribute of the associated class
8. Class diagram — Aggregate relationship (Aggregation)
Aggregate relationship (Aggregation) It means the relationship between the whole and the part , The whole and the part can be separated . Aggregation is a special case of association , So it's associated with navigation and multiplicity .
Such as : A computer consists of a keyboard (keyboard)、 Monitor (monitor), Mouse, etc ; The components of a computer can be separated from the computer , Use a solid line with a hollow diamond to represent .
public class Computer{
private Mouse mouse;
private Monitor monitor;
public void setMouse(Mouse mouse){
this.mouse = mouse;
}
public void setMonitor(Monitor monitor){
this.monitor = monitor;
}
}Class diagram : polymerization

Summary :
Aggregate relationship (Aggregation) It means the relationship between the whole and the part , The whole and the part can be separated .
9. Class diagram — synthetic relation (Composition)
synthetic relation : It's also the relationship between the whole and the part , But the whole cannot be separated from the part .
Let's look at another case : In the program we define the entity :Person And IDCard、Head, that Head and Person Namely Combine ,IDCard and Person It's polymerization .
But if in the process Person The entity defines right IDCard Cascade delete , Delete immediately Person Together with IDCard Delete... Together , that Well IDCard and Person It's a combination .
public class Person{
private IDCard card;
private Head head = new Head();
}
public class IDCard{}
public class Head{}Class diagram : Combinatorial aggregation

public class Computer {
private Mouse mouse = new Mouse(); // Mouse can and computer Can't separate
private Moniter moniter = new Moniter();// The monitor can be connected with Computer Can't separate
public void setMouse(Mouse mouse) {
this.mouse = mouse;
}
public void setMoniter(Moniter moniter) {
this.moniter = moniter;
}
}
public class Mouse {
}
public class Moniter {
}Class diagram : Combine

Summary :
When the composite reference class is instantiated , The referenced class is also instantiated
边栏推荐
- 如何区分平台安全和网上炒作?网络投机有哪些止损技巧?
- Solution to the conflict between unique index and logical deletion
- CTFSHOW权限维持篇
- Introduction to digital transformation solutions for enterprises going to sea
- Manage edge browser settings (ie mode, homepage binding, etc.) through group policy in the enterprise
- 未来十年世界数字化与机器智能展望
- ABAQUS 2022 latest edition - perfect realistic simulation solution
- 一次革命、两股力量、三大环节:《工业能效提升行动计划》背后的“减碳”路线图
- How to distinguish between platform security and online hype? What are the stop loss techniques for online speculation?
- lvm-snapshot:基于LVM快照的备份之准备工作
猜你喜欢

Why should VR panoramic shooting join us? Leverage resources to achieve win-win results
![[fundamentals of wireless communication-13]: illustrated mobile communication technology and application development-1-overview](/img/1d/62e55f1b5445d7349ec383879f4275.png)
[fundamentals of wireless communication-13]: illustrated mobile communication technology and application development-1-overview

让企业数字化砸锅和IT主管背锅的软件供应链安全风险指北

ABAQUS 2022 software installation package and installation tutorial

Shell multitasking to download video at the same time

shell 同时执行多任务下载视频

Two way data binding in wechat applet

Online customer service chat system source code_ Beautiful and powerful golang kernel development_ Binary operation fool installation_ Attached construction tutorial

5G智慧建筑解决方案2021

"Paddle + camera" has become a "prefabricated dish" in the AI world, and it is easier to implement industrial AI quality inspection
随机推荐
Why should VR panoramic shooting join us? Leverage resources to achieve win-win results
Netease cloud sign in lottery? That year I could sign in for 365 days. No? Look.
Don't worry about whether you can be a coder if you don't learn English well. Learn it first
Summer Challenge [FFH] harmonyos mobile phone remote control Dayu development board camera
Sm2246en+ SanDisk 15131
The college entrance examination in 2022 is over. Does anyone really think programmers don't need to study after work?
Matlab saves triangulation results as STL files
Is it safe to choose mobile phone for stock trading account opening in Guangzhou?
Bridge emqx cloud data to AWS IOT through the public network
In 2022, the latest JCR officially released the list of the latest global impact factors (top 600)
Fund customer service
lvm-snapshot:基于LVM快照的备份
[golang] golang implements the string interception function substr
One revolution, two forces and three links: the "carbon reduction" road map behind the industrial energy efficiency improvement action plan
股票开户要如何办理呢?办理手机开户安全吗
Fastjson V2 simple user manual
Asynchronous transition scenario - generator
Cesiumjs 2022 ^ source code interpretation [6] - new architecture of modelempirical
Redis - 01 缓存:如何利用读缓存提高系统性能?
Arthas debugging problem determination Toolkit