In the Corona tool, the way we do it is to mark a property as read-only and custom storage.
Then we override the method GetValueForCustomStoredAttribute of the model element in question and do the calculation there.
It wouldn't be wise to rely on rules or events for this "calculated" property.
In future this will certainly change - we're still working our what it will change to.
Gareth -
TIA,
Richard
Alan Cameron Wills wrote:
In the Corona tool, the way we do it is to mark a property as read-only and custom storage.
Then we override the method GetValueForCustomStoredAttribute of the model element in question and do the calculation there.
It wouldn't be wise to rely on rules or events for this "calculated" property.
In future this will certainly change - we're still working our what it will change to.
Gareth
-
You don't want to store a property value that is calculated based on other information in the model. That's duplication, and if your own experience hasn't (yet) taught you this is a bad idea, I hope you won't think I'm patronising you if I suggest you trust the collected wisdom of things like database normalization and the Don't Repeat Yourself principle.
The normal change is to move the calculation of that value to the generator. If necessary, you can also add an element to the visual representation of the object that shows the calculated value (in MetaEdit+ that would be a text element whose content comes from running a generator; I don't think such a thing exists out of the box in the MS DSL tools, but no doubt you could hand-code one).
Of course, the visual representation will by default not update when the values that contribute to it are changed, especially if they are pulled in from other objects a long way off, but that's rarely a real problem.
Best regards,
Richard
Steven Kelly wrote:
You don't want to store a property value that is calculated based on other information in the model. That's duplication, and if your own experience hasn't (yet) taught you this is a bad idea, I hope you won't think I'm patronising you if I suggest you trust the collected wisdom of things like database normalization and the Don't Repeat Yourself principle.