Book a Demo

Author Topic: Adding attributes to MDG stereotype element  (Read 5871 times)

Evandro

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Adding attributes to MDG stereotype element
« on: May 29, 2018, 11:22:48 pm »
Hi there,
I've just created my MDG technology to speed up modellig. Now in the toolbox I've got my stereotyped class element, with attributes of the stereotype that have become my tags (perfect). But what if I need the same set of attributes to be included in my class element every time?
Is there a way to avoid creating them each time for a new element?

Thanks, E.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding attributes to MDG stereotype element
« Reply #1 on: May 30, 2018, 12:04:18 am »
I don't get it. If you drag your stereotype from the toolbox you will tagged values, but no attributes. Eventually you can look into Patterns which can also be included in a MDG (not sure about creation of attributes right there).

q.

Evandro

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Adding attributes to MDG stereotype element
« Reply #2 on: May 30, 2018, 12:17:22 am »
Precisly, I get tagged values. Now if I want +50 class to also have the same 4 attributes (which values I'll change later), how can I speed up this process? Do I have to drag and drop manually the attributes onto each one of the +50 elements?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding attributes to MDG stereotype element
« Reply #3 on: May 30, 2018, 01:10:09 am »
Likely so. There's also a feature I haven't really used which is called Template Packages. You put in elements and it will create "similar" elements in your diagrams. That will probably do what you need.

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Adding attributes to MDG stereotype element
« Reply #4 on: May 30, 2018, 01:12:20 am »
Precisly, I get tagged values. Now if I want +50 class to also have the same 4 attributes (which values I'll change later), how can I speed up this process? Do I have to drag and drop manually the attributes onto each one of the +50 elements?

Yes, in terms of UML Profiles: you can't specify a set of attributes or operations to be created on all classes of a certain stereotype, only a set of tagged values.

The proper UML way to repeat attributes is to use generalization. You can tell EA to display the inherited attributes in the specialized class by right-clicking the class in a diagram and select Features & Properties -- Feature and Compartment Visibility.

The same submenu has the item Override Attribute Initializers, which you can use to set values for both local and inherited attributes. You can also (ab)use this to show certain inherited attributes selectively by giving them an initial value of a single white space.

HTH,


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

Nizam

  • Prolab Moderator
  • EA User
  • *
  • Posts: 320
  • Karma: +15/-2
  • Model Sharing - Simplified
    • View Profile
    • Professional Model Collaboration
Re: Adding attributes to MDG stereotype element
« Reply #5 on: May 30, 2018, 09:56:47 am »
Precisly, I get tagged values. Now if I want +50 class to also have the same 4 attributes (which values I'll change later), how can I speed up this process? Do I have to drag and drop manually the attributes onto each one of the +50 elements?

For anything with attributes (or features), template package is preferred, however I would usually do the Scripting way to achieve something like this.  As this may not be always expected off a stereotype and may vary from one context to another (typically).

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Adding attributes to MDG stereotype element
« Reply #6 on: May 30, 2018, 10:21:57 am »
The proper UML way to repeat attributes is to use generalization.

+1

If you have 50+ classes all with the same 4 attributes, that is a poorly designed class model. Create an abstract superclass with 4 attributes and inherit from it.
The Sparx Team
[email protected]

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Adding attributes to MDG stereotype element
« Reply #7 on: May 31, 2018, 02:27:40 am »
I should add that the Override Attribute Initializers function allows you to override the initial values of any attributes up the generalization hierarchy, regardless of whether they've already been overridden in any intermediate classes.

So if what you're after is specifying different values of the same-named attributes in different classes, generalization is definitely the way to go.

Of course, if you're looking to create different instances of the same class with different values in the same set of attributes, that's what objects and run states are for.

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