2

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.

Christophe
  • 68,716
  • 7
  • 72
  • 138
  • Somewhat simplified: Composition - `struct F { struct SomeOtherStruct x; };` Association - `struct F { struct SomeOtherStruct *x; };` In the composition case `x` is a part of the object created from the structure `F`. In the association case `x` references another object, but it's not part of objects created from `F`. – Some programmer dude Apr 27 '22 at 05:36
  • @Someprogrammerdude in the same document it says "In general it is pure modeling taste whether an aggregation is shown as class attribute or explicit association" and "Metaclasses defined within the same M2 model MUST be aggregated in form of explicit associations and aggregations" which I interpret that associations (regular and compsition) are some kind of attribute but since they are not primitive(i.e int, float) we use association to model them which means that they are part of class. – Ahmad Banshee Apr 27 '22 at 05:47
  • @Ister I already studied it but that was not my answer or too vague for Autosar domain. What I found from all is that Associations(either regular or composition) lifecycle is dependent of associating class but there is a tiny difference between them. in Autosar, composition is used in a module, if the module is determining the structure of associated class and regular is used, if the structure of associated class determined by another module other than associating module – Ahmad Banshee Apr 27 '22 at 07:14
  • for more explanation, in composition associating is complete control over associated class including structure of associated class and make an object inside itself but in case of regular association, the associating class must know about the structure of associated class(does not have control over structure) and make an object inside itself – Ahmad Banshee Apr 27 '22 at 07:25
  • Maybe you should have made the title more clear with your intention. UML has only one definition, so maybe Autosar is doing something bad? – qwerty_so Apr 27 '22 at 07:29
  • 1
    @qwerty_so Well Autosar is a profile on UML 2, I mentioned Autosar in Title and also I tagged Autosar, Also I explained Autosar point of view about association. If you have something to add which can improve the idea I am happy to hear. – Ahmad Banshee Apr 27 '22 at 11:04
  • I think this question is not a full duplicate : it is very specific to the autosar profile, which for example prohibits the use of shared aggregation if I understood well. Moreover it asks the question in the context of links by reference. I therefore propose to reopen it. – Christophe Apr 27 '22 at 18:05
  • 1
    For the record: an InstanceRef is NOT „used for reference for independent object with independent lifecycle“. An InstanceRef represents a ordered bundle of references that identify contexts (created by utilizing the type-prototype pattern in the AUTOSAR meta-model) in the concrete model structure and finally one reference to the target element. – Uwe Honekamp Apr 27 '22 at 18:33
  • Maybe I was to quick with closing. So I reopened your question. I now remember that there's a profile with that name but it was never in my focus. And the diagram really looks broken (see comment on Jens' answer). – qwerty_so Apr 27 '22 at 19:02

2 Answers2

1

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.

kesselhaus
  • 1,241
  • 8
  • 9
0

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

Jens
  • 570
  • 3
  • 11
  • when dealing with Associations(including regular, shared composition and strict composition) we are dealing with objects and and we should interpret in a way that concepts shown in class diagram make sense. in your case I interpret that there are two distinct object of a1 and a2 one is part of A and the other is part of B. but I can not understand what do you mean by this answer to my question – Ahmad Banshee Apr 27 '22 at 06:04
  • Where in the diagram did you see such a double-composite aggregation? – qwerty_so Apr 27 '22 at 08:44
  • I did not see it, but question (2) was „why is there no composition used“ and this is the answer. Com Group signal is already owned by another class. – Jens Apr 27 '22 at 08:47
  • Found it: bottom right to the config via two paths so the config is composite to two objects which is wrong. – qwerty_so Apr 27 '22 at 09:08
  • @qwerty_so, it is not wrong. It would be wrong if the multiplicities were `1`, but in the diagram, the multiplicities are not specified, so they might as well be `0..1`. Take `A <>- C -<>B`. This can lead to instances `a:A <>- c1:C` and `b:B <>- c2:C`. – www.admiraalit.nl Apr 28 '22 at 14:56
  • @www.admiraalit.nl You are right I always get fooled by such constructs :-( – qwerty_so Apr 28 '22 at 15:15