Default String Representation and asString
No edit summary
No edit summary
Line 4: Line 4:


====== Note on performance ======
====== Note on performance ======
asString and the DefaultStringRepresentation is not subscribed. This means that every time the asString is used, it needs to be reevaluated. For better performance, create a derived attribute, for example "Presentation" with the OCL and then use self.Presentation in DefaultStringRepresentation.
asString and the DefaultStringRepresentation are not subscribed. This means that every time the asString is used, it needs to be reevaluated. For better performance, create a derived attribute, for example "Presentation" with the OCL and then use self.Presentation in DefaultStringRepresentation.


Also, avoid using asString in other expressions that need to have high performance, because they can not subscribe properly if you use asString in the expression tree.
Also, avoid using asString in other expressions that need to have high performance, because they can not subscribe properly if you use asString in the expression tree.


Keyword: Defaultstringrepresentation, asString
Keyword: Defaultstringrepresentation, asString

Revision as of 14:34, 16 July 2022

You can use asString on all objects in OCL (the same was you can to in C# for example)

When you use asString, the DefaultStringRepresentation is used to get the result string.

Note on performance

asString and the DefaultStringRepresentation are not subscribed. This means that every time the asString is used, it needs to be reevaluated. For better performance, create a derived attribute, for example "Presentation" with the OCL and then use self.Presentation in DefaultStringRepresentation.

Also, avoid using asString in other expressions that need to have high performance, because they can not subscribe properly if you use asString in the expression tree.

Keyword: Defaultstringrepresentation, asString

This page was edited 84 days ago on 02/10/2024. What links here