Author Topic: How to create a "has"-relationship between 2 objects?  (Read 11300 times)

F@lk

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
How to create a "has"-relationship between 2 objects?
« on: December 11, 2020, 08:38:34 pm »
Hi,

I have an object diagram with 2 objects I created by drag'n'drop from the model tree which was parsed from my C++ source code. I noticed there is not automatically an arrow between two objects although one object is an attribute of the other object and there is also a parent pointer back. So I manually created an accociation arrow between both created objects. But now the question is how can I show a "has"-relationship? My toolbox just offers: Accociate, Depedency, Realize, Trace, Information Flow, Abstraction, Substitution, Usage, Derive, Refine, Responsibility, Note Link. I have the feeling they are all not what I understand as "one has the other one"-relationship.

Thanx in advance,
-- F@lk

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: How to create a "has"-relationship between 2 objects?
« Reply #1 on: December 11, 2020, 08:55:51 pm »
Hello,

The "has" relationship is normally expressed in UML using a composition or aggregation, but it's a property of classes, not objects.
With objects what you can do is express the relationship at the class level as attributes, and then in the objects set the run state of the containing object to the name of the contained object. This has to be maintained manually, there's no automation that helps you keep it updated.

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

F@lk

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: How to create a "has"-relationship between 2 objects?
« Reply #2 on: December 11, 2020, 09:35:42 pm »
...express the relationship at the class level as attributes...
I parsed my C++ source code and there is actually already that relationship because the classes have their proper attributes, I mean class A has an attribute of class B.

...and then in the objects set the run state of the containing object to the name of the contained object...
What do you exactly mean here? Is it something how I can tweak the accociation arrow between two objects?

Furthermore, I tried a Composite Structure diagram but it also has no support of "has"-relationship arrows between objects. I just wonder what such "property" stuff means, which makes no sense if you have parsed C++ classes with attributes and methods and create object instances from them.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: How to create a "has"-relationship between 2 objects?
« Reply #3 on: December 11, 2020, 09:49:09 pm »
...and then in the objects set the run state of the containing object to the name of the contained object...
What do you exactly mean here? Is it something how I can tweak the accociation arrow between two objects?

No, but you can name the instance of class B and then set that as the corresponding attribute's value in the A instance's run state.

Quote
Furthermore, I tried a Composite Structure diagram but it also has no support of "has"-relationship arrows between objects. I just wonder what such "property" stuff means, which makes no sense if you have parsed C++ classes with attributes and methods and create object instances from them.

In UML, such relationships are expressed using classes. Since every instance of a class will "have" the same contents, there's no point in expressing that in object diagrams.

/U
My theories are always correct, just apply them to the right reality.

F@lk

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: How to create a "has"-relationship between 2 objects?
« Reply #4 on: December 11, 2020, 10:02:13 pm »
No, but you can name the instance of class B and then set that as the corresponding attribute's value in the A instance's run state.
I see. Hmm, I actually want the arrow to be of type "has".


In UML, such relationships are expressed using classes. Since every instance of a class will "have" the same contents, there's no point in expressing that in object diagrams.
I want to create a software structure survey, and I have an object "server" having 3 members (=attributes) of class "Connection". Each connection calls its own callstack to different connected objects. I need the has-relationship arrow to illustrate such scenario. This is for the docs to show via UML how the main software concept is built.