TheBlur
TheBlur

Reputation: 21

Relationship of a class which creates object to the created object UML

I am not sure which relationship between classes would be adequate for a class which returns a created object or gets an object as parameter(see uploaded picture). I guess that aggregation/composition is wrong since Class1 does not own the object/does not have it as an attribute. Also I think that an association is wrong since Class1 does not refers to a pointer.

Thank you in advance for any answers. enter image description here

Upvotes: 2

Views: 843

Answers (2)

qwerty_so
qwerty_so

Reputation: 36313

That would simply be dependencies:

enter image description here

An association is created in case you have a stronger relation between classes. That is either one is holding a more permanent relation (in form of an attribute) rather than a temporary one like in using them as passing parameter or return parameter. From an UML point of view an association is basically a stronger form of a dependency.

Note that the untyped attributes you sketched are of no interest in this context and I just left them out.

According to a comment of @www.admiraalit.nl: If Class1 creates new instances of Class3, the dependency may have the ≪create≫ stereotype, see table 22.1 of the UML spec. v2.5.1. In that case the dependency would be a usage (chap. 7.8.23) which is just a bit stronger

Upvotes: 3

bruno
bruno

Reputation: 32596

a class which returns a created object or gets an object as parameter(see uploaded picture)

you mean for a class having an operation returning ... and an other getting ...

I guess that aggregation/composition is wrong since Class1 does not own the object/does not have it as an attribute

you are right

Also I think that an association is wrong since Class1 does not refers to a pointer.

whatever by pointer or by value (which is target language dependent) an association is not right because there is no attribute in Class1 whose type is Class2 or Class3

The only possible relation between Class1 and Class2 or Class3 seems to be a dependency, but to have them does not have a real plus value, the profile of the operations already give that information

Upvotes: 0

Related Questions