JADE Environment Development Ideas

What's new in the upcoming JADE release?

IMPROVED DEVELOPER EFFICIENCY. ENHANCED SECURITY. SMOOTHER INTEGRATION

The JADE 2022 release meets tomorrow’s business demands.


Start your update to JADE's latest release

Method to fire when Collection Edition Changes

Essentially the idea is to have a method like the create and delete methods that Jade calls as part of an edition change to a collection.

The Collection objects have an Edition which is updated whenever a collection is changed, if as a result of that change Jade automatically called a method called "changed" (or something similar) which could be reimplemented and coded to perform actions.

I know people will argue that we could manage this on the set method of the inverse, however in the situation I want to use it, there are multiple inverses and lots of different actions which makes it hard to manage and the chances of missing one is high.

  • Julian Meates
  • May 4 2021
  • Needs review
  • Attach files
      Drop here to upload
    • Kevin Saul commented
      June 02, 2021 08:47

      In the example given, the collection edition would only change when line items are added/removed, it wouldn't change if/when the line item amount is changed (assuming it's not a key value, but if it were you could just iterate/sum the key values). With that in mind, I'm not convinced the solution requested solves the use case.

      Presumably, each line item knows about it's parent invoice - a simple mapping method could be used to adjust the total stored by the parent invoice when the line item amount is set/changed - Would that help to solve the problem?

    • Julian Meates commented
      May 19, 2021 01:20

      The real power of the concept is for Storing Calculated values, and knowing if the stored value is accurate or not. If I have a collection of objects on something, say a Sale Invoice has a collection of line items, each of which has a total, then I can calculate the total of the line items and store that value on the Sale Invoice itself. If someone asks for the value I can check if my stored value is accurate or not, if it is I would return it, if not I would recacluate it and then store the new value.

      The challenge is testing if the Stored value is accurate or not. I can do it by storing the edition of the Collection, and checking if the collection edition is the same as the stored value collection edition, and that works. However when the stored value is based on more than 1 collection this method doesn't work anymore, and it all becomes very complex very quickly.

      If I had the EditionChanged method, then I could go and tell all the Stored values they are not longer up to date and so any request for their values would automatically force a recalculate.

      The problem with using notifications is that the system could go down between the notification being raised and processed, in which case the notification would be lost and therefore I can not rely on the stored values being accurate.


    • Ty Baen-Price commented
      May 04, 2021 21:42

      How about Object::beginClassNotification listening for Object_Update_Event?