Author Topic: Message to self in UML Class diagram  (Read 1111 times)

flitjens

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Message to self in UML Class diagram
« on: November 02, 2022, 11:57:43 pm »
Hello all,

I would like to know if it is possible to show dependencies to self in a class diagram as an association instead of a member variable when the class diagram is generated by importing code.

For example:
I have a LinkedList pointing to the root of type ListItem. ListItem has to references to itself, _next and _previous.

The dependency from LinkedList to ListItem is presented as an association with label _root, but _next and _previous of ListItem is only showed as private member. For clarity I would like to present them as an association.

Is that possible?

Kind regards,

Frank Litjens

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12784
  • Karma: +533/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Message to self in UML Class diagram
« Reply #1 on: November 03, 2022, 12:07:10 am »
Unfortunately, there little you can do with regards to reverse engineering code.

Geert

flitjens

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Message to self in UML Class diagram
« Reply #2 on: November 03, 2022, 12:39:18 am »
Hi Geert,

Thanks for your quick response. Is it possible than to add that association in the model without affecting the underlying code?

Kind regards,

Frank Litjens

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12784
  • Karma: +533/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Message to self in UML Class diagram
« Reply #3 on: November 03, 2022, 12:49:17 am »
For forward engineering, you can change the templates, so you should be able to do so without affecting the code.
But I'm not sure if this is a route you want to be traveling on.

I try to stay as far away as possible from the code generation templates.

Geert

jfzouain

  • EA User
  • **
  • Posts: 151
  • Karma: +6/-1
    • View Profile
Re: Message to self in UML Class diagram
« Reply #4 on: November 09, 2022, 03:34:14 am »
Hi Frank

I will stay away from changing the template as Geert says, but if I understood you correctly you can show dependency to self in a class, add it to the Operation Return Type = > Self

Regards

Jose
Best regards

Jose Zouain

jfzouain

  • EA User
  • **
  • Posts: 151
  • Karma: +6/-1
    • View Profile
Re: Message to self in UML Class diagram
« Reply #5 on: November 09, 2022, 03:42:29 am »
Operation:
 
Name: Init
Parameters: object, ushort
Return type: Self
 -> Go to the code and include the code there

It will generate the code correctly

Sorry had issues pasting the class diagram, so included only 1 operation
Best regards

Jose Zouain