当前位置:网站首页>【UML】UML的几种关系(依赖-关联-聚合-组合-继承-实现)
【UML】UML的几种关系(依赖-关联-聚合-组合-继承-实现)
2022-06-30 00:24:00 【weixin_43224306】
UML几种关系:
2.1 依赖关系(Dependency)
依赖关系是一种使用关系,特定事物的改变有可能会影响到使用该事物的其他事物,在需要表示一个事物使用另一个事物时使用依赖关系。大多数情况下,依赖关系体现在某个类的方法使用另一个类的对象作为参数。
在UML中,依赖关系用带箭头的虚线表示,由依赖的一方指向被依赖的一方。
依赖关系实例
在系统实施阶段,依赖关系通常通过三种方式来实现
- 第一种也是最常用的一种方式是如图所示的将一个类的对象作为另一个类中方法的参数
- 第二种方式是在一个类的方法中将另一个类的对象作为其局部变量
- 第三种方式是在一个类的方法中调用另一个类的静态方法
2.2 关联关系(Association)
类与类之间最常用的一种关系,它是一种结构化关系,用于表示一类对象与另一类对象之间有联系
如汽车和轮胎、师傅和徒弟、班级和学生等等。
在UML类图中,用实线连接有关联关系的对象所对应的类
在使用Java实现关联关系时,通常将一个类的对象作为另一个类的成员变量
在使用类图表示关联关系时可以在关联线上标注角色名,一般使用一个表示两者之间关系的动词或者名词表示角色名(有时该名词为实例对象名),关系的两端代表两种不同的角色,因此在一个关联关系中可以包含两个角色名,角色名不是必须的,可以根据需要增加,其目的是使类之间的关系更加明确。
边栏推荐
猜你喜欢

vsftp 与 TFTP 与 samba 与 nfs 复习

Quick pow: how to quickly find power
![[advanced C language] special user-defined type](/img/f3/c01b8b10e02860afc88a216ff8dbce.png)
[advanced C language] special user-defined type

网工常见面试题分享:Telnet、TTL、路由器与交换机

SOFARegistry 源码|数据同步模块解析

Five key elements of the data center

Three postures of anti CSRF blasting

There is no web-based development for the reward platform. Which is suitable for native development or mixed development?

Activity invitation | the Apache Doris community essay and speech solicitation activity has begun!

Finding a job in 2022 is the "last lesson" for graduates
随机推荐
代码分析平台 SonarQube 实战
MySQL primary key constraint deletion
01背包问题
Summarize Flink runtime architecture in simple terms
@ConfigurationProperties使用不当引发的bug
IO stream summary
Clone undirected graph [bfs accesses each edge but not only nodes]
01 backpack problem
Automatic integration: yescomusa, an overseas cross-border e-commerce, cooperates with cloud expansion to realize one-stop Automation Service
Code analysis platform sonarqube actual combat
证券开户有优惠吗究竟网上开户是否安全么?
mysql 死锁
克隆无向图[bfs访问每条边而不止节点]
QT learning 07 coordinate system in QT
[uitableview] Pit 1: tableview:heightforheaderinsection: method does not execute
Root cause of glideexception: failed decodepath{directbytebuffer- > gifdrawable- > drawable}
label问题排查:打不开标注好的图像
Applying for let's encrypt SSL certificate with certbot
Store log files in RAM to reduce physical storage loss
gyctf_ 2020_ document