In Enterprise Architect I modified an interface, how to update the realizing classes?

9,630

Solution 1

I have also searched for the answer to this question, but apart from your post I didn't find anything. I posted a question on the EA Forum.

If it is for diagram purposes only, there 1 possible workaround (but a bit nasty):

  • Add your interface to the diagram as an (abstract) class with the <<interface>> stereotype
  • Add your class to the diagram as a class with the <<implementingClass>> stereotype
  • Add a generalization relationship from the class to the interface, don't select any checkbox in the Overrides & Updates
  • Hide the connector
  • Add a realization relationship from the class to the interface
  • Right-click on the class > Feature Visibility > check the Show Operations checkbox

As a result

  • The abstract class with look like an interface on the diagram
  • The implementing class will show the inherited operations
  • When adding operations to the interface, the class will be updated
  • When modifying operations on the interface, the class will be updated

The only problem is that during code generation an abstract class is generated instead of an interface.

Solution 2

Select the class you want to refresh, and press Ctrl + Shift + o.

This link gives you a detailed explanation.

In Enterprise Architect, you can automatically override methods from parent Classes and from realized Interfaces.

Select a Class that has a parent or realized interface and select the Element | Advanced | Overrides & Implementations menu option.

In the Override Operations/Interfaces dialog, check the operations/interfaces to automatically override and click on the OK button. Enterprise Architect generates the equivalent function definitions in your child Class.

You can configure Enterprise Architect to display this dialog each time you add a Generalization or Realization connector between Classes, and review their possible operations/interfaces to override/implement. Do this from the Links page of the Options dialog (select the Tools | Options | Links menu option).

Share:
9,630

Related videos on Youtube

Timo
Author by

Timo

Updated on September 17, 2022

Comments

  • Timo
    Timo almost 2 years

    I've created an interface in a class model. This interface has two methods, A and B and method A takes an argument (a) and method B does not take an argument (yet). Additionally I've created a class that implements this interface, overriding both methods.

    After a discussing the model method B now should also take a parameter (b), so I modified the interface to reflect this change. However the class realizing this interface is not updated automatically. For one class it's possible to add the method by re-creating the link between the interface, specify the which method should be implemented and deleting this link again. Then the OLD method signature has to be removed as well. This is a lot of work if there is more then one class implementing the modified interface, not to mention error-prone.

    Does anybody know how to make an entire class model update this type of dependency?

  • Timo
    Timo over 11 years
    This does not cover adding or removing parameters from a method. Nor does it cover removing a method from the interface. Additionally this is still manual work which I am simply to lazy to do.
  • Timo
    Timo over 11 years
    This is the answer I was looking for, especially since I don't need to generate code from the diagram. Additionally it also works when removing a method from the interface.
  • raiserle
    raiserle almost 9 years
    Is there a way, to do this automatically without calling the overrides-dialog?