Book a Demo

Author Topic: unique stereotypes names in one profile?  (Read 6609 times)

Palm

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
unique stereotypes names in one profile?
« on: November 11, 2019, 08:46:09 pm »
Do stereotypes need to have unique names in one profile?
I developed a UML profile and associated MDG for class diagrams with multiple metaclasses and related stereotypes with the same name. The stereotype is called <<Choice>> and is defined three times. But each time as an extension of a different UML metaclass. One <<Choice>> as extension of (EA)UML-attribute, another one as (EA)UML-Class and one as extension of (EA)UML-Association. Sofar so good. Though I was a little bit surprised that metaclasses with the same name could be included in one metaclass diagram.

However the generated UML-profile and the MDG include only one of the Choice stereotypes. So it seems that stereotype names need to be unique in one UML profile. My question: Do stereotype names need to be unique in one profile? And if so. Is there a shortcut to overcome this?

Thanks for any advice.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: unique stereotypes names in one profile?
« Reply #1 on: November 11, 2019, 10:14:38 pm »
If you want to refer them in toolboxes you need to write something like

MyProfile::MyStereo(UML::Class)
MyProfile::MyStereo(UML::Object)


to distinguish between the two incarnations.

q.


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: unique stereotypes names in one profile?
« Reply #2 on: November 11, 2019, 10:26:57 pm »
I think they should be unique yes.
Even if EA allowed you to define multiple stereotypes with the same name in the same profile, I would still avoid it.

Geert


peterc

  • Guest
Re: unique stereotypes names in one profile?
« Reply #3 on: November 12, 2019, 12:59:30 am »
I was using the same stereotype to redefine different Metaclasses, so it is technically possible to have multiple uses of one stereotype name.

My personal opinion is that it is not wise - I'd inherited it from a custom MDG, but further customisation gave me an issue as I could not find a way to distinguish between the two different uses (the exact details of why escape my mind) and I ended up changing one to a different stereotype to ensure uniqueness.

Like Palm's suggestion, one was an element and one a relationship in my case.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: unique stereotypes names in one profile?
« Reply #4 on: November 12, 2019, 01:41:56 am »
It's definitely possible.

If you look in the XML data, under a <Stereotype> element you'll find something like
Code: [Select]
<AppliesTo>
<Apply type="Class">
<Property name="isActive" value=""/>
</Apply>
</AppliesTo>

... which strongly implies there could be more than one "Apply type".

But just as definitely, I would not recommend overloading stereotypes. It's iffy in the tool and can be iffy wrt understanding as well.

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

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: unique stereotypes names in one profile?
« Reply #5 on: November 12, 2019, 09:04:15 am »
You can have any number of Extension connectors from a <<stereotype>> class to <<metaclass>> classes.
The Sparx Team
[email protected]

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: unique stereotypes names in one profile?
« Reply #6 on: November 12, 2019, 11:00:09 am »
You can have any number of Extension connectors from a <<stereotype>> class to <<metaclass>> classes.
But still only one stereotype for each name. You can't have a different set of tagged values associated with the different metaclasses.

Palm

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: unique stereotypes names in one profile?
« Reply #7 on: November 12, 2019, 10:50:34 pm »
Thanks to all, This forum works great. I still have some extra information to clearify the issue. I copy some lines from the MDG:

Two Choice stereotypes are defined:

<Stereotype name="Choice" notes="" cx="0" cy="0" bgcolor="-1" fontcolor="-1" bordercolor="-1" borderwidth="-1" hideicon="0">
   <AppliesTo>
      <Apply type="Attribute"/>
   </AppliesTo>
</Stereotype>

<Stereotype name="Choice" notes="." cx="0" cy="0" bgcolor="16777164" fontcolor="0" bordercolor="0" borderwidth="1" hideicon="0">
   <AppliesTo>
      <Apply type="DataType"/>
   </AppliesTo>
</Stereotype>

Each has a Toolbox item:


<Tag name="MIM::Choice(UML::DataType)" type="" description="" unit="" values="" default="Choice datatype"/>
<Tag name="MIM::Choice(UML::Attribute)" type="" description="" unit="" values="" default="Choice attribute"/>

This seems logic. And shows up in the toolbox when loaded. However only the first Choice defined, the one applied to  attribute will actually work. The second one, applied on datatype will have an error like:

Missing base type: 'Choice' does not extent 'UML::DataType'
Command: MMIM::Choice(UML::DataType)


When I change the order, that is, firtst define the Choice on DataType. Only the DataType will work. So it seems that only the first is actually implemented.

My question is if this could have been expected or is something wrong (some where)?



Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: unique stereotypes names in one profile?
« Reply #8 on: November 12, 2019, 11:18:54 pm »
Can't tell for sure, but it looks like you've got multiple stereotype elements with the same name in your profile, each relating to a different metaclass. You can't do that, that's what KP and Eve were talking about.

You can create a single stereotype element and link it to multiple metaclasses, which should give you one <Stereotype> node with multiple <Apply> nodes in the XML file.

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

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: unique stereotypes names in one profile?
« Reply #9 on: November 13, 2019, 09:09:16 am »
Change it to:

Code: [Select]
<Stereotype name="Choice" notes="" cx="0" cy="0" bgcolor="16777164" fontcolor="0" bordercolor="0" borderwidth="1" hideicon="0">
<AppliesTo>
<Apply type="Attribute"/>
<Apply type="DataType"/>
</AppliesTo>
</Stereotype>
The Sparx Team
[email protected]

Palm

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: unique stereotypes names in one profile?
« Reply #10 on: November 15, 2019, 02:46:41 am »
Thanks.
Your solution does work when the <<Choice>> stereotype has the same definition and more important no, or the same set of tagged values. However, I need different sets of tagged values for each specific <<Choice>>. A <<Choice>> applied to Attribute has different tagged values than a <<Choice>> applied to DataType.

It seems that this is not possible in a profile or a MDG.

Paul


Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: unique stereotypes names in one profile?
« Reply #11 on: November 15, 2019, 03:39:01 am »
It's possible in a technology, but not in a profile. Move them to separate profiles and it should work.

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

Palm

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: unique stereotypes names in one profile?
« Reply #12 on: November 15, 2019, 10:51:06 pm »
Major breakthrough. It does indeed work when I define each <<Choice>> in a separate profile and combine them in one toolbox profile. And later combine everything in one MDG. Perfect!

thanks again!