Home > Software design >  What is the difference between Association and Composition Aggregation in Autosar domain
What is the difference between Association and Composition Aggregation in Autosar domain

Time:04-28

I am reading Autosar document and in one of the document (Autosar_TemplateModelingGuideline.pdf), it says that:

Composite aggregation, forming a whole-part relationship

Regular association, expressing a reference from the associating to the associated model element

My question is: what is the difference between these two in practice? How do I have to interpret them in a class diagram, e.g. the Com Module in Autosar.:

The AUTOSAR COM module’s Configuration Overview

Consider Specified class ComGwSignalRef surrounded with a red rectangle. This class has a composition relation with ComGwSignalRef class and two regular association with ComGroupSignal and ComSignal.

How would you interpret this as a developer and how do you implement in C?

  1. if regular association is a reference to an object that has independent life from ComGwSignalRef why designer do not use instanceRef here?

  2. if it is not a reference, why did the designer not use composition?

PS. There is a concept in Autosar "InstanceRef" which is used for reference for independent object with independent lifecycle.

CodePudding user response:

An object can only be composed as part of one object.

A <>- C -<>B

In the diagram above C is composed in A and B. This would lead to the following instances:

a: A <>- c: C -<> b:B

Now the specific instance c is now part of both a and b.

What happen would with c if b goes out of scope? By the semantics it should be destroyed and not be destroyed (a still exists).

Or more pointed: Take Alice,Bob, and Collar Bone as examples. Alice’s collar bone cannot be part of Bob.

UML is a modeling language and has not the same expressiveness as, say a C compiler. This is by design to simplify things.

Remember: All models are wrong, but some are useful. — George E. P. Box

CodePudding user response:

Maybe you should also consider the following:

The Com Configuration is an instance of the EcuC configuration meta-model as defined in the AUTOSAR_TPS_EcuConfiguration.

The ComGwSignalRef is of type EcucChoiceContainerDef, and as such, the two destination associations of ComSignal and ComGroupSignal have a meaning. Only one of these "choices" can be selected in the final configuration as a reference. In AUTOSAR metamodel, that is the definition of how EcucChoiceContainerDef works, in UML you might need here an additional constraint element to define the XOR relation of two associations.

  • Related