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。
下图第4行代码会自动天生一个[0,n]的从root节点到Item节点的composition。