UML之類別圖讀書筆記 – 1

參考網站:

https://misomiso43.medium.com/%E7%B0%A1%E5%96%AE%E7%90%86%E8%A7%A3-uml-%E9%A1%9E%E5%88%A5%E5%9C%96-f0b32a3272c

Difference between association and dependency?

https://stackoverflow.com/questions/1230889/difference-between-association-and-dependency

Aggregation v.s. Composition:

https://en.wikipedia.org/wiki/Object_composition#Aggregation

UML類別圖功能:

1. 釐清各類別的描述、擁有的屬性、可使用的方法與各物件間的相互關聯

2.表示實作的Design pattern

描述類別:

– name

– attributes

– methods

表示封裝層級:

+、-、#、~、/、__

public、private、protected、package、derived、static

描述關係:

分為兩部分:

– 類別間的關係:

inheritance、implementation

– 實體間的關係:

aggregation、composition、dependency、association

Detail:

Aggregation & Composition都表達have的關係,但有差別,以下說明:

– composition:

A is a composition of B.

A be killed, B also be killed.

– aggregation:

A has an aggregation of B.

A be killed, B is not affected.

例子:

大學、科系、教授之間的關係

大學有許多科系,大學關閉後,科系也不在了。

(composition)

一個科系有許多教授,科系關閉了,教授還在。

(aggregation)

(以下未完成)

Dependency和Association都表達use的關係:

Association 表示one object has the other object as field/property/attribute

Dependency表示one object accepts another object as a method parameter、return type