2024-03-03 08:00:04

UML箭头的解释

我最近一直在学习UML,并在类之间用普通的箭头绘制简单的图,但我知道这还不够。还有很多其他的箭头:概括,实现等等,这些对图表读者有意义。

是否有一个很好的资源可以解释每个箭头(普通,普通,虚线,钻石填充,钻石)?

这将是最好的,如果它将为他们提供一些代码示例。


当前回答

Aggregations and compositions are a little bit confusing. However, think like compositions are a stronger version of aggregation. What does that mean? Let's take an example: (Aggregation) 1. Take a classroom and students: In this case, we try to analyze the relationship between them. A classroom has a relationship with students. That means classroom comprises of one or many students. Even if we remove the Classroom class, the Students class does not need to destroy, which means we can use Student class independently.

(作文) 2. 看看页面和书类。 在本例中,pages是一本书,这意味着书页的集合构成了这本书。如果我们删除book类,整个Page类将被销毁。这意味着我们不能独立地使用页面的类。

如果你对这个话题仍然不清楚,请观看这个精彩的短视频,它更清楚地解释了聚合。

https://www.youtube.com/watch?v=d5ecYmyFZW0

其他回答

如果你更喜欢MOOC,我推荐一门免费课程,它可以教你大多数UML图的所有内容,这门课程来自Udacity: https://www.udacity.com/course/software-architecture-design--ud821

一个非常容易理解的描述是yuml的文档,其中有类图、用例和活动的示例。

我最喜欢的UML“小抄”是Martin Fowler的《UML Distilled》。这是我读过的唯一一本推荐他的书。

我认为这些图片是可以理解的。

Aggregations and compositions are a little bit confusing. However, think like compositions are a stronger version of aggregation. What does that mean? Let's take an example: (Aggregation) 1. Take a classroom and students: In this case, we try to analyze the relationship between them. A classroom has a relationship with students. That means classroom comprises of one or many students. Even if we remove the Classroom class, the Students class does not need to destroy, which means we can use Student class independently.

(作文) 2. 看看页面和书类。 在本例中,pages是一本书,这意味着书页的集合构成了这本书。如果我们删除book类,整个Page类将被销毁。这意味着我们不能独立地使用页面的类。

如果你对这个话题仍然不清楚,请观看这个精彩的短视频,它更清楚地解释了聚合。

https://www.youtube.com/watch?v=d5ecYmyFZW0