Book a Demo

Author Topic: updating attributes/operations within subclass  (Read 3806 times)

juanPablos

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
updating attributes/operations within subclass
« on: July 03, 2008, 05:44:55 pm »
Is there anyway to dynamically update/synchronize attributes and operations within a class that extends another class?.

I have a Logical Diagram, I'm dragging out elements from the Class Toolbox, filling in Attributes and Operations, then drawing out Class Relationships.

So here's what I have:
1. An abstract (base) class
2. An implementation class
3. A Realization connector (creating a relationship between the two).

After the 3rd step, the Overrides & Implementations window opens and lists all operations/interfaces that can be overriden/implemented. so I select all operations and hit OK.

The implementation class populates correctly with all the operations, but when I go back to the abstract class and (for example) change an operation's name, the change isn't reflected in the concrete class.

How do you (is it possible) update/sync operations between elements?.

Could be using the wrong type of diagram?.

Note: I'm using EA to generate stub code, so all I'm looking to do here is create the entire application in one diagram (aprox 15-20 classes/elements) then generate all stub code for further implementation.

Thanks.
« Last Edit: July 03, 2008, 05:50:54 pm by juanPablos »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: updating attributes/operations within subclass
« Reply #1 on: July 03, 2008, 08:54:19 pm »
AFAIK this is not possible, nor is it really a flaw in the product. [That is, given how EA is expected to work.]

If you want to synchronize everything you will need to use or create a transformation and run that. For more real time results you might create an MDG add-in program and trap change events from your elements.

Of course we could always lobby Sparx to add attributes to elements and features that would tell EA which things to propagate to other phases, and in which directions. These would have to be specific to methodologies since not all work the same. Users would want to tweak these for their own situations, so would create custom add-ins... You see where I'm going.
No, you can't have it!

juanPablos

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: updating attributes/operations within subclass
« Reply #2 on: July 03, 2008, 10:06:53 pm »
Thanks midnight. I've since made inroads on this.

I dragged a Decorator pattern from the Resources Panel (located in the UML Patterns > GoF Structural Patterns folder) onto the stage, and when changes are made to an abstract operation within an abstract bass class, the changes are reflected in all subclasses.

It needs to be a Generalized relation drawn from the subclass to the interface. Then with both elements, right click their diagram, select Feature Visibility, and check both Show Attributes and Show Operations under Inherited Features.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: updating attributes/operations within subclass
« Reply #3 on: July 03, 2008, 11:03:26 pm »
Yes, that works fine.

I somehow misunderstood what you'd said - you said it clearly, the failure was mine - in your first post, and answered a (completely) different question.

You don't need to copy a pattern to do this. [Though using patterns remains a useful skill, of course.]

Any generalization will act this way. You do not even have to generalize an abstract base class - though that is what you are doing in this case - for this to work. EA will correctly propagate changes in parent classes down through the class hierarchy for you.

You are correct in setting the feature visibility to see the inherited structural and behavioral features. Unfortunately this seems to be a setting you've got to make each time - we've asked for changes in this but so far without success - although you can select multiple (or all with control-A) the elements on a diagram and set feature visibility of the selected set at once.

Sorry about the earlier miscue.

HTH, David
No, you can't have it!

juanPablos

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: updating attributes/operations within subclass
« Reply #4 on: July 04, 2008, 05:16:57 pm »
Thanks midnight - much appreciated. Yes setting them all at once is handy. Cheers.

I've another question about attributes but will start a new thread.
« Last Edit: July 04, 2008, 05:19:35 pm by juanPablos »