Book a Demo

Author Topic: How to distinguish between Aggregation and Composition?  (Read 5094 times)

michielper

  • EA User
  • **
  • Posts: 176
  • Karma: +2/-1
    • View Profile
How to distinguish between Aggregation and Composition?
« on: October 10, 2020, 12:41:12 am »
Although in models and diagrams there is a distinction between Aggregation and Composition, this seems to be lost when accessing the model in a script where both types of connectors get the same EA.Connector.Type: "Aggregation". This seems weird, or am I missing something?

Although the two relationship types have similarities, the differences can be very significant and essential in a model. So, how can I find the difference when accessing the model from a script?

Regards, Michiel

pvickers

  • EA User
  • **
  • Posts: 44
  • Karma: +7/-0
    • View Profile
Re: How to distinguish between Aggregation and Composition?
« Reply #1 on: October 10, 2020, 01:08:50 am »
In the repository see table t_connector.
The indication of a connector being "aggregate" is shown with a value of 1 in column "DestIsAggregate"...
If it has a value of 2 it is composite.

Hope this helps.
Perry

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to distinguish between Aggregation and Composition?
« Reply #2 on: October 10, 2020, 01:29:13 am »
Yeah, don't realy on the connector type. An connector of type association can also be an Aggregation or Composition.
Check the aggregate properties at both ends.

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8617
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: How to distinguish between Aggregation and Composition?
« Reply #3 on: October 10, 2020, 11:04:19 am »
Yeah, don't rely on the connector type. A connector of type association can also be an Aggregation or Composition.
Check the aggregate properties at both ends.

Geert
To echo what Geert says and also provide some historical context (in case you come across an ancient repository).  In the "old days" Aggregation and Composition arcs were of type "Aggregation" with the subtype = Strong for Composition.  As UML evolved, Sparx converted to a more consistent mechanism whereby all three "Association", "Aggregation" and "Composition" were all of type "Association" differing only in their AggregationKind (none, shared, composite) (DestIsAggregate, SourceIsAggregate).

For your sanity, try to standardise on which end the AggregationKind is to be applied.  We have made all such arcs, be Direction: Source -> Destination with AggregationKind (compisitionKind in MDG) at the Destination end.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!