1
votes

In Enterprise Architect, I want to have operation prototypes of a child class to be updated automatically when I change a prototype in the interface the class implements. How do I do that? It seems so trivial!

I'm using the realization connection to specify that a class implements an interface. When I create such a connection, AE asks me which operations to implement. If I select none (default) and press ok, no methods are shown in the class. So far, so good. I expected the operations of the interface to show up when I change the feature visibility of that class to show inherited operations. But they don't! Why is this?

If I delete the connection, make it again and this time select all operations to be implemented/overridden, then all methods (of course) are added to the class. However, when I change an operation's prototype in the interface, the prototype of that same operation in the class is not updated. I don't want to manually have to update all classes. Is there a way to do this?

For the record, I'm busy designing interfaces and classes using Enterprise Architect v8.0 for a C++ project. Interfaces will be generated by AE as pure virtual classes with all abstract methods. These methods are specified automatically in EA as pure and abstract.

1

1 Answers

1
votes

First off, I don't use EA to generate code, but here's what it does in UML terms. Also I'm on 9.0, but I'm pretty sure this behaviour hasn't changed.

The Feature Visibility option is strict: it shows Inherited Features - not Realized ones. AFAIK, there is no way to display Realized Features. But they're still there, underneath, and they work the way you want them to.

If MyInterface contains MyMethod, and MyClass realizes MyInterface without overriding any operations, MyMethod is available to select as a Message in a Sequence Diagram (provided you select to Show Inherited Methods). Changes to MyInterface::MyMethod are reflected correctly in MyClass, and MyMethod is also inherited (but hidden) by children of MyClass.

Overriding, on the other hand, creates new Operations in the Class. Once that's been done, the Operations are no longer considered inherited, and do not follow changes made to the ones in the Interface.

The behaviour you're asking for is what you get if you use Classes and Generalizations: the child Class inherits its parent's Operations, and displays them if you select Inherited Features in the Feature Visibility dialog. The Operations are not copied to the child Class but are available as Messages in a Sequence, and changes to the parent's Operations are reflected in the child.

So if you need the methods displayed in diagrams, a workaround might be to ditch Interfaces and use abstract Classes instead. Which would work best for C++ generation I couldn't say.