UI5
UI5使用Association和Aggregation描述控件之間的關系。
Aggregation:parent和子控件在lifecycle上存在依賴關系:
When a ManagedObject is destroyed, all aggregated objects are destroyed as well and the object itself is removed from its parent. That is, aggregations won’t contain destroyed objects or null/undefined.
比如UI5的轉盤控件Carousel: 一旦轉盤被析構,裡面顯示的page當然也沒有繼續存在的意義了,需要跟着被析構。
而Association描述了在lifecycle層面的一種soft dependency關系:
Managed associations also form a relationship between objects, but they don’t define a lifecycle for the associated objects. They even can ‘break’ in the sense that an associated object might have been destroyed already although it is still referenced in an association.
最明顯的例子就是控件和其label的關系,比如button和label:技術上來說,可以彼此分開獨立存在。
CRM
CRM的Genil model存在三種類型的relation,可以在doman CRM_RELATION_KIND裡檢視:
差別:
Association: Link between any kind of objects. Can also be defined across components with root or access object as target. 依賴關系最為loose的一種relation,可以用來連接配接跨model之間的節點。
Aggregation: Binds child objects to a root object. Only access and dependent objects can be aggregated. 隻适用于同一模型的節點之間的關聯。
Composition: Like an aggregation, but composed child objects always exist. 特殊類型的Aggregation。目标節點的Cardinality為1或者1…n
S/4HANA
隻有兩種:association或者composition。Composition的含義同CRM裡的aggregation,而association的含義同UI5和CRM中的association一緻。
C4C
隻有兩種: association或者composition。C4C的這兩種relation多了一個限制:relation的目标BO必須和源BO在同一個部署單元Deployment Unit,或者目标BO位于Foundation部署單元内。
Association的文法如下圖:
association的multiplicity隻支援[0,1]或者[1,1], 如果不顯式指定,預設為[1,1].
C4C relation的一個特色是,一旦申明了一個子節點之後,系統會預設生成一個對應的composition。