In the GOF23 book [Design Patterns Elements of Reusable Object-Oriented Software], there is pseudocode annotation in the class diagrams. It is a very helpful tool.

But I can not find the counterpart in UML class diagrams, so would like to know if there is the counterpart of pseudocode annotation in UML class diagrams
One can claim that the above is illegal UML (since the note connector is wrong). However, you can just attach the note to the class and augment the note (to show the operation which is meant).
Enterprise Architect shows behavior like this:

(the blabla is the behavior).
Note: I have to check with the UML specs whether this is legal UML. Though EA is quite compliant, it has a few flaws too.
Edit: I have checked the UML 2.5 specs. Pseudo code is not really mentioned and there's no place where they tell how to show it. Only with Actions/States they talk about showing behavior. E.g. on p. 329:
the optional
<behavior-expression>is an expression specifying the effect Behavior written in some vendor-specific or standard textual surface language (see sub clause 16.1)
So it's up to you to "invent" your notation, document it in your domain, and use it appropriately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With