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?
if regular association is a reference to an object that has independent life from
ComGwSignalRef
why designer do not useinstanceRef
here?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.
An object can only be composed as part of one object.
In the diagram above
C
is composed inA
andB
. This would lead to the following instances:Now the specific instance
c
is now part of botha
andb
.What happen would with
c
ifb
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