How to represent calling base class method in overridden method?

不想你离开。 提交于 2019-12-22 09:56:40

问题


I have a child class which wants to add more functionality to a base class function, how can I represent that it also does the base class function not just the newly added functionality?


回答1:


Interesting question. I tried that with Enterprise Architect. It did let me select the parent's operation but the display in the diagram did not change. It seems like you need to use notes for that:

As you can see Class2 inherits from Class1. The SD shows a call to Class2's operation a(). The call to the super-class's Class1.a() as internal call shows the same signature. A note clarifies the situation.

Maybe there's something else possible with this. But that's what I came up with immediately.


P.S. I've looked up the specs. P. 575 of UML 2.5 says

The message-name appearing in a request-message-label is the name property of the Message. If the Message has a signature, this will be the name of the Operation or Signal referenced by the signature. Otherwise the name is unconstrained.

That would put in the option to specify the operation in question as Class1:a() or the like. Actually Enterprise Architect shows it that way in the properties of the message but shortens it to just the basic name. Just a border case, I'd guess.



来源:https://stackoverflow.com/questions/58787705/how-to-represent-calling-base-class-method-in-overridden-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!