Sparx Systems Forum

Enterprise Architect => Bugs and Issues => Topic started by: lvantine on June 04, 2010, 12:37:25 am

Title: Overriding Attributes
Post by: lvantine on June 04, 2010, 12:37:25 am
When inheriting from another class EA offers you the a list of Methods from the parent class from which you can select which Methods you want included in the child class to be overridden. Is there any way to get EA to also offer you the Attributes so you can select which ones to override?
Title: Re: Overriding Attributes
Post by: Paul Lotz on June 04, 2010, 04:26:32 am
Overriding only applies to methods (behaviors) in UML and in OOP.

One doesn't really need to override an attribute.  A child class can use the attribute defined on the parent class.
Title: Re: Overriding Attributes
Post by: lvantine on June 04, 2010, 05:52:54 am
Thanks for the reply, such is life. We are using EA to model DMTF MOF which has highly decorated attributes which can be overriden with an extensive set of qualifies. Being able to override attributes in a child class with a little automation would have been a great time saver. :-/
Title: Re: Overriding Attributes
Post by: Eve on June 04, 2010, 08:27:21 am
Find the parent class in the project browser, drop the attributes you want to override onto the child in the diagram.
Title: Re: Overriding Attributes
Post by: Paul Lotz on June 04, 2010, 10:50:11 am
Hmm...  I clearly didn't know what you were trying to do, and I don't know anything really about DMTF-MOF.

Are you essentially trying to do this: http://www.sparxsystems.com/uml_tool_guide/modeling/displayinginheritedattribute.htm (Display Inherited Attributes) but be able to change a set of qualifiers that are along the same lines as the initial value?  Do you just need to have a copy of the attributes or show them as overrides?   I guess I'm just curious.
Title: Re: Overriding Attributes
Post by: Geert Bellekens on June 04, 2010, 03:58:23 pm
Paul,

Overriding (or "Redefining" in UML terms) is actually applicable for all element features (so including attributes).
In practice this is done (as with operations) by having a feature with the same name in the child classifier.
EA indeed provides a facility to easily copy operations using the Override dialog, but the result is exactly the same as copying the operations the way Simon described.

Geert
Title: Re: Overriding Attributes
Post by: lvantine on June 04, 2010, 09:16:22 pm
Thanks for everyone's help, the drag and drop function is just what I needed.
Title: Re: Overriding Attributes
Post by: Paul Lotz on June 05, 2010, 04:27:00 am
OK, this issue appears to be resolved, but I want to know for my own edification, I guess:

I'm curious how one ends up with redefinition of an attribute in this way.  Don't we just end up with a copy and hence a new attribute?

I tried implementing the equivalent of the resulting diagram from the "drag existing attribute to the child class approach"  in the OO language I use.  I created ClassA and an attribute on it named speed.  Then I created ClassB, made it a child of ClassA, and defined an attribute on ClassB that I also called speed (drag and drop isn't meaningful in the development environment).  Then I wrote a method on ClassB that writes 5 to B's speed attribute and 2 to the inherited speed attribute (using an accessor method on A for the latter).  In this example B does not redefine A's attribute--both exist simultaneously.

What is possible is to write an init method on each class (for example), and the init method would write a unique value in either case.  I could show this in EA using an override init method, of course, or more compactly (if a bit less accurately) using the Display Inherited Attributes option.  Or perhaps there is an OO language that can truly override an attribute?  I know the language I use can't.  I'm curious if there is one that can and what that actually means....

Sorry but I'm really curious about this!
Title: Re: Overriding Attributes
Post by: Paolo F Cantoni on June 05, 2010, 09:42:36 am
Hi Paul,

Eiffel has the most comprehensive Generalization/Realization technology I know of...

Early on in my Forum life, I posted some thoughts on how Generalization/Realization should be specified in the arc and would include the kinds of things mentioned here.  See: What and How should things get Specialized? (http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1121063415) (and it's referenced links).

Basically, the arc describes the transformations desired.  This would therefore allow the Supplier to change and the Client to be refactored accordingly.

I believed then and still do - that this type of change would make EA very powerful...

HTH,
Paolo
Title: Re: Overriding Attributes
Post by: Geert Bellekens on June 07, 2010, 04:09:52 pm
I recently discovered a new feature in EA regarding redefining attributes.
The "Detail" tab now contains a section for both the "Redefined" and "Subsetted" properties.
I guess this way you can store the actual override relation between an attribute on the subclass and the attribute on the superclass.

Geert
Title: Re: Overriding Attributes
Post by: Paolo F Cantoni on June 07, 2010, 07:21:17 pm
Quote
I recently discovered a new feature in EA regarding redefining attributes.
The "Detail" tab now contains a section for both the "Redefined" and "Subsetted" properties.
I guess this way you can store the actual override relation between an attribute on the subclass and the attribute on the superclass.

Geert
I didn't notice that mentioned in the release notes... (for any recent version).  Can anyone point me at the reference?  A search of the Latest Releases didn't reveal a mention of "Redefined".

Paolo
Title: Re: Overriding Attributes
Post by: Geert Bellekens on June 07, 2010, 07:43:00 pm
Quote
Added Subsetting, redefining capabilities for Attributes, Ports and Parts.

In UML Specific part of the 855 release notes.

Geert
Title: Re: Overriding Attributes
Post by: Paolo F Cantoni on June 08, 2010, 09:50:13 am
Quote
Quote
Added Subsetting, redefining capabilities for Attributes, Ports and Parts.

In UML Specific part of the 855 release notes.

Geert
No wonder search didn't find it...

Thanks Geert.