Association, Composition and Aggregation in UI5, CRM, S/4HANA and C4C
UI5
UI5使用Association和Aggregation描述控件之間的關(guān)系。
Aggregation:parent和子控件在lifecycle上存在依賴關(guān)系:
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的轉(zhuǎn)盤控件Carousel: 一旦轉(zhuǎn)盤被析構(gòu),里面顯示的page當(dāng)然也沒(méi)有繼續(xù)存在的意義了,需要跟著被析構(gòu)。
而Association描述了在lifecycle層面的一種soft dependency關(guān)系:
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的關(guān)系,比如button和label:技術(shù)上來(lái)說(shuō),可以彼此分開(kāi)獨(dú)立存在。
CRM
CRM的Genil model存在三種類型的relation,可以在doman CRM_RELATION_KIND里查看:
區(qū)別:
-
Association: Link between any kind of objects. Can also be defined across components with root or access object as target. 依賴關(guān)系最為loose的一種relation,可以用來(lái)連接跨model之間的節(jié)點(diǎn)。
-
Aggregation: Binds child objects to a root object. Only access and dependent objects can be aggregated. 只適用于同一模型的節(jié)點(diǎn)之間的關(guān)聯(lián)。
-
Composition: Like an aggregation, but composed child objects always exist. 特殊類型的Aggregation。目標(biāo)節(jié)點(diǎn)的Cardinality為1或者1…n
S/4HANA
只有兩種:association或者composition。Composition的含義同CRM里的aggregation,而association的含義同UI5和CRM中的association一致。
C4C
只有兩種: association或者composition。C4C的這兩種relation多了一個(gè)限制:relation的目標(biāo)BO必須和源BO在同一個(gè)部署單元Deployment Unit,或者目標(biāo)BO位于Foundation部署單元內(nèi)。
Association的語(yǔ)法如下圖:
association的multiplicity只支持[0,1]或者[1,1], 如果不顯式指定,默認(rèn)為[1,1].
C4C relation的一個(gè)特色是,一旦申明了一個(gè)子節(jié)點(diǎn)之后,系統(tǒng)會(huì)默認(rèn)生成一個(gè)對(duì)應(yīng)的composition。
下圖第4行代碼會(huì)自動(dòng)生成一個(gè)[0,n]的從root節(jié)點(diǎn)到Item節(jié)點(diǎn)的composition。
要獲取更多Jerry的原創(chuàng)技術(shù)文章,請(qǐng)關(guān)注公眾號(hào)"汪子熙":
總結(jié)
以上是生活随笔為你收集整理的Association, Composition and Aggregation in UI5, CRM, S/4HANA and C4C的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 折叠屏价格屠夫!摩托罗拉razr 40
- 下一篇: 徕卡超大杯首次进军海外!小米13 Ult