当前位置:网站首页>UML class diagram
UML class diagram
2022-06-10 12:25:00 【shangzh!】
UML Class diagram
Basic introduction
- 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
- UML Itself is a set of symbolic regulations , Just like mathematical symbols and chemical symbols , These symbols are used to describe the elements in the software model and the relationship between them , Such as class 、 Interface 、 Realization 、 generalization 、 rely on 、 Combine 、 Polymerization, etc. .

Dependency relationship
- As long as the other party is used in the class , Then there is a dependency between them . If there's no one else , Can't even compile .
Code instance
public class PersonServiceBean {
private PersonDao personDao; // class
public void save(Person person){
}
public IDCard geIDCard(Integer personid){
return null;
}
public void modify(){
Department department = new Department();
}
}
public class PersonDao {
}
public class Person {
}
public class IDCard {
}
public class Department {
}
Class diagram 
Summary
- Class uses the other side
- If it's a member property of a class
- If it's the return type of the method
- Is the receiving parameter type of the method
- Method used in
Generalization relation
- Generalization is actually inheritance
Code instance
public class DaoSupport {
public void save(Object entity){
}
public void delete(Object id){
}
}
public class PersonServiceBean extends DaoSupport{
}
Class diagram 
Summary
- Generalization is actually inheritance
- If A Class inherited B class , Then we can say A and B There is a generalization relationship
Realization relationship
- Realizing a relationship is actually A Class implements the B class
Code instance
public interface PersonService {
public void delete(Integer id);
}
public class PersonServiceBean implements PersonService{
@Override
public void delete(Integer id) {
System.out.println("delete...");
}
}
Class diagram 
Connections
- Association is actually the relationship between classes , The association is navigable , A two-way or one-way relationship , Correlation has multiplicity .
One way one-on-one relationship
Code instance
public class Person{
private IDCard card;
}
public class IDCard{
}
Two way one-on-one relationship
Code instance
public class Person{
private IDCard card;
}
public class IDCard{
private Person person;
}
Aggregate relationship
- An aggregate relationship is a 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 center to represent .
Code example
public class Computer {
private Mouse mouse; // Mouse can and computer Separate
private Moniter moniter; // The monitor can be connected with computer Separate
public void setMouse(Mouse mouse){
this.mouse = mouse;
}
public void setMoniter(Moniter moniter){
this.moniter = moniter;
}
}
public class Moniter {
}
public class Mouse {
}
Class diagram 
synthetic relation
- Whole and part cannot be separated
Code instance
public class Computer {
private Mouse mouse = new Mouse(); // The mouse cannot be connected with computer Separate
private Moniter moniter = new Moniter(); // The monitor cannot be connected with computer Separate
public void setMouse(Mouse mouse){
this.mouse = mouse;
}
public void setMoniter(Moniter moniter){
this.moniter = moniter;
}
}
Class diagram 
边栏推荐
- Green Alliance database firewall (das-fw) has obtained Kunpeng validated certification
- Surrender firehouse database access: Twitter is ready to meet Musk's requirements
- (11) Const decorated member function
- Shadergraph - Crystal
- Shadergraph - 301 bouncing ball
- Talk about message oriented middleware (1) and AMQP
- Oceanbase, phase II of the document promotion plan, invites you to jointly build documents
- Daniel recommended and hanged the interviewer
- 【严选】,真题解析
- UML类图
猜你喜欢
随机推荐
Unity3D开发MR实现模型遮挡与透明地面接收阴影
漏扫工具学习笔记
SQL Server AlwaysOn查看数据同步进度
掌握高性能计算前,我们先了解一下它的历史
Web server development, small company web development
CF894C Marco and GCD Sequence
通过反射获取枚举值
Gimp - free and open source image processing software with powerful functions, known as an excellent substitute for Photoshop
Green Alliance database firewall (das-fw) has obtained Kunpeng validated certification
极简随机音乐播放器
阿里云ECS服务器搭建Mysql数据库
Ad-pcb schematic diagram learning (1)
Shadergraph - 303 swaying grass
Stm32f407 learning notes (1) -exti interrupt event and NVIC register
【已解决】vagrant up下载box速度太慢的解决方法
Dom4j parsing XML
聊聊消息中间件(1),AMQP那些事儿
(11) Const decorated member function
Zipoutputstream use
ShaderGraph——301跳动的小球









