自动将原型更改更新为企业架构师中的子类

发布于 2024-11-25 02:16:24 字数 449 浏览 1 评论 0原文

在Enterprise Architect中,我希望当我更改子类实现的接口中的原型时,可以自动更新子类的操作原型。我该怎么做?看起来是那么的微不足道!

我使用实现连接来指定一个类实现一个接口。当我创建这样的连接时,AE 会询问我要执行哪些操作。如果我选择“无”(默认)并按“确定”,则类中不会显示任何方法。到目前为止,一切都很好。我希望当我更改该类的功能可见性以显示继承的操作时,会显示界面的操作。但他们没有!这是为什么呢?

如果我删除连接,再次创建连接,这次选择要实现/覆盖的所有操作,然后所有方法(当然)都会添加到类中。但是,当我更改接口中操作的原型时,类中相同操作的原型不会更新。我不想手动更新所有课程。有办法做到这一点吗?

根据记录,我正忙于使用 Enterprise Architect v8.0 为 C++ 项目设计接口和类。接口将由 AE 生成为具有所有抽象方法的纯虚拟类。这些方法在 EA 中自动指定为纯方法和抽象方法。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深者入戏 2024-12-02 02:16:24

首先,我不使用 EA 生成代码,但以下是它在 UML 术语中的作用。我也用的是 9.0,但我很确定这种行为没有改变。

“功能可见性”选项很严格:它显示继承的功能 - 而不是已实现的功能。 AFAIK,没有办法显示已实现的功能。但它们仍然在那里,在下面,并且它们按照您希望的方式工作。

如果 MyInterface 包含 MyMethod,并且 MyClass 实现 MyInterface 而不覆盖任何操作,则 MyMethod 可在序列图中选择为消息(前提是您选择“显示继承的方法”)。对 MyInterface::MyMethod 的更改会正确反映在 MyClass 中,并且 MyMethod 也由 MyClass 的子级继承(但隐藏)。

另一方面,重写会在类中创建新的操作。完成此操作后,操作将不再被视为继承,并且不会遵循对接口中的操作所做的更改。

如果您使用类和泛化,您所要求的行为就是您所得到的:子类继承其父类的操作,并在您在“特征可见性”对话框中选择“继承特征”时显示它们。操作不会复制到子类,而是作为序列中的消息提供,并且对父类操作的更改会反映在子类中。

因此,如果您需要图表中显示的方法,解决方法可能是放弃接口并使用抽象类。我不能说哪个最适合 C++ 一代。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文