Book a Demo

Author Topic: MDG - Override Attribute Initializers - set value for inherited attribute  (Read 380 times)

MarcinG

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
    • View Profile
Hi,

I have a stereotype, say Server, that extends a Node.  That Server has attributes like IsPhysical that can have value s Yes/No.  Now, I have another stereotype, called Some Server that extends server.  It has its own properties, but inherits IsPhysical.  I would like to be able to specify use of specific value for this IsPhysical.
I have tried using Override Attribute Initializers, and it shows nicely in the profile diagram, but does not actually set value for the property when creating a new instance of the Some Server.

Thank you for any ideas.
Marcin

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13445
  • Karma: +570/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: MDG - Override Attribute Initializers - set value for inherited attribute
« Reply #1 on: September 25, 2025, 11:01:27 pm »
Can't you simply redefine the same attribute on SomeServer, but with another initial value?

Geert

MarcinG

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
    • View Profile
Can't you simply redefine the same attribute on SomeServer, but with another initial value?

Geert
Not very elegant, right ?  That's what Inheritance is for, to avoid doing things like this manually.  The extended class shows Inherited properties, it is just setting default value so a property that has Enum as type.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13445
  • Karma: +570/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Can't you simply redefine the same attribute on SomeServer, but with another initial value?

Geert
Not very elegant, right ?  That's what Inheritance is for, to avoid doing things like this manually.  The extended class shows Inherited properties, it is just setting default value so a property that has Enum as type.
I would be happy if "not very elegant" was the level of improvements we would be on with EA.
Unfortunately there are many, way worse issues on the level of "broken" or "actively harmful"

Geert

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1161
  • Karma: +30/-8
    • View Profile
Unfortunately there are many, way worse issues on the level of "broken" or "actively harmful"

That sounds a bit scary and off-putting.

I have a stereotype, say Server, that extends a Node.  That Server has attributes like IsPhysical that can have value s Yes/No.  Now, I have another stereotype, called Some Server that extends server.  It has its own properties, but inherits IsPhysical.  I would like to be able to specify use of specific value for this IsPhysical.
I have tried using Override Attribute Initializers, and it shows nicely in the profile diagram, but does not actually set value for the property when creating a new instance of the Some Server.
I agree with this but I have given up hope of getting any improvements on how Sparx EA handles inheritance, specifically attribute inheritance.

What I would like to see are things like being able to
  • assign default values to inherited attributes (as per the original post)
  • select what attributes are inherited or not
  • be able to include inherited attributes in the documentation (not sure if this is possible)

The other thing that catches my attention about the OP is that it may be able to solve the problem through instantiation. But he more I used other modelling languages - e.g., ArchiMate - the less comfortable I am with instantiation.

Elpis

  • EA User
  • **
  • Posts: 58
  • Karma: +7/-0
  • Make MDA/MBSE vital.
    • View Profile
Can't you simply redefine the same attribute on SomeServer, but with another initial value?
Not very elegant, right ?  That's what Inheritance is for, to avoid doing things like this manually.  The extended class shows Inherited properties, it is just setting default value so a property that has Enum as type.

As Geert said "simply redefine the same attribute", I guess, he had in his mind an UML-compliant redefinition ({redefines ...}) of inherited property (and not simple copy of the property in specialized class). See UML 2.5.1 "9.2.3.3 Redefinition". So as an 'UML way', I wouldn't consider this 'not elegant way'. ;)
BTW "Redefinition" is applied in many places in UML specification/metamodel itself, as well. And specifically, for re-setting default value of an inherited property in specialized meta-class.


Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1161
  • Karma: +30/-8
    • View Profile
I cannot read Geert's mind but I am not sure the way "redefinition" is done in Sparx EA is elegant or compliant with the UML specification. In particular, "Specifically, any reference to a redefined member in the context of an instance of the specializing Classifier shall resolve to the redefining member."

As far as I know, there is no way to specify a redefinition or substitution relationship between elements - i.e., classes or components - or attributes of a class or a component.


Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1161
  • Karma: +30/-8
    • View Profile
Just an update, redefinition can be done closer to the UML specification in a very inelegant way.

Quick steps:
1) Create 2 classes A and B
2) Add 2 attributes to class : a and b
3) Create a relationship between classes B and A, with the realisation arrow on the A side
4) Add an attribute to class B: a
5) Edit the attribute and click on the 3 dots next to "Redefined property" and select the redefined attribute from class A. If it needs to be given a default value, specify an "Initial Value"

There is also a "Subsetted Property" which I do not know what it could be used for.

If I had designed this, I would have a wizard that allows me to specialise a class or component, class A in the example, and handle all of this in a single operation.


Elpis

  • EA User
  • **
  • Posts: 58
  • Karma: +7/-0
  • Make MDA/MBSE vital.
    • View Profile
Just an update, redefinition can be done closer to the UML specification in a very inelegant way.
I'm not sure, what you mean by "inelegant way" here... is it how EA itself handles that case?

Quote
What I would like to see are things like being able to
  • assign default values to inherited attributes (as per the original post)
You are able. UML-compliant "redefinition" is a way to do it. :-)

Quote
  • select what attributes are inherited or not
AFAIK UML standard decides on that:
"The set of members that are inherited is called the inheritedMembers. Unless specified differently for a particular kind of
Classifier, the inheritedMembers are members that do not have private visibility"



Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1161
  • Karma: +30/-8
    • View Profile
I'm not sure, what you mean by "inelegant way" here... is it how EA itself handles that case?
A more accurate word could be counterintuitive. The goal is to redefine a classifier - e.g., a class - not to define two classifiers and then refine one of them to make it a redefinition of the other. A more intuitive way would be to right click on a class or component, select a a "Redefine" menu item, specify on a screen how it would be redefine -  e.g., through an specialisation, what attributes are inherited, and what are redefined - and create the redefined class or component on pressing "OK/Save".

UML-compliant "redefinition" is a way to do it. :-)
The result may be UML compliant, with the exception that it does not allow specifying that the default value is the result of a redefinition. But it is a very convoluted way of achieving a compliant result.

Which one of the following options do you prefer?
  • 2000 + 25 = 2025
  • (6!/2) x 5 + 225 = 2025

Sparx EA does too many things, mostly advanced, using ways similar to option 2. It produces a compliant result but it takes a long time to figure it out and verify it. It also gives the tool a bit of reputation.

AFAIK UML standard decides on that:
"The set of members that are inherited is called the inheritedMembers. Unless specified differently for a particular kind of
Classifier, the inheritedMembers are members that do not have private visibility"
Indeed but, AFIK, Sparx EA inherits all attributes by default and there is not an easy way to just inherit some attributes.