问题
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