Skip to main content

EXAMPLE: List-based Scope

Let’s return to the architecture example where Jasmira the junior developer introduced some architectural refinements. Sh did not explicitly added a ‘scope’ mechanism to the architecture yet. Adding that mechanism was not really necessary because the scope was limited to two objects an OrderLine and an Order which where both passed from the NewEdit page.

In this example we assume that a scope mechanism is necessary for this microflow hierarchy. We choose to implement the List Based Scope.

1. Context

The microflow hierarchy used in the architecture example saves the OrderLine (OLNE) and is updating the Order (ORDR) object because the total order amount must be re-calculated whenever an OrderLine is added, changed or deleted.

In order to commit both objects via a list-based scope we need two commit lists that contain the changed objects: ORDRs_toCommit and OLNEs_toCommit.

Both list are ‘traveling’ top to bottom through the microflow hierarchy until they reach the commit microflow (CMT) that will commit or rollback the objects on the lists.

This example is addressing the following steps:

  • Create an ‘Add To Scope’ helper microflow which is used to add objects on the list.
  • Change each operator (OPR) microflow so it will add the changed or created object on the scope list.
  • Alter the committer microflow (CMT) to commit all objects on the scopelist.
  • Change every orchestration in order to pass the scopelists. The top orchestration microflow also creates the ORDRs_toCommit scopelist because Orders are not handled by the touchpoint microflow (ACT).
  • Change the ACT microflow so it will create the OLNEs_toCommit scopelist.

2. Creating an ‘Add To Scope’ microflow

First, Jasmira creates a helper microflow that adds a changed object to a scope-list. The resulting FTN microflow first tries to remove the object from the scope, to prevent duplicate instances of the object on the scope, then adds the changed object to the scope.

image-20251124-123754.png

3. Changing the Operator Microflows

According the the Menditect Testability Framework, each operator microflow (OPR) is responsible for adding it’s changed objects to the scope. So Jasmira is now changing all OPR microflows to achieve that. Each OPR get the scope-list as input parameter and calls the ‘add to scope’ function microflow after the change. For example, the resulting OPR microflow that changes the Order amount now looks like:

image-20251124-123850.png

4. Passing the Scope Lists to the Commit Microflows

Next, Jasmira changes the Commit Microflow (CMT). This microflow will get the scope-lists and process all objects on them. It now pays off that she had added all validations in rule-families because she can call each family instead of each validation.

image-20251125-141830.png

5. Changing the Orchestration Microflows

When all OPR and CMT microflows were changed, Jasmira ended up with construction errors because the scope-lists ORDRs_toCommit and ONLEs_toCommit are not passed to the OPR microflows by the ORC microflows. So she went on and added the scope-lists to each ORC microflow until she reaches the top microflow ORC_one_save.

Now Jasmira need to decide if the scope-lists should be created by the top-orchestration microflow ORC_olne_saveor by the touchpoint microflow ACT_olne_newedit_save.

The framework defines a clear rule for creating the scope lists: The ACT microflow is responsible for creating and populating commit lists for objects that originate from the user interface (touchpoint data). All other commit lists, which contain data manipulated solely by the server, must be initialized by the top-level orchestration (ORC) microflow.

Because the Order object is not changed by the OLNE_NewEdit page, Jasmira creates the scope-list ORDRs_toCommit in the the top microflow ORC_olne_save. The list is passed to the microflows ORC_ordr_set_amount and the CMT_olne_save.

image-20251124-124121.png

6. Changing the Touchpoint Microflow

Finally, Jasmira changes the touchpoint microflow ACT_olne_newedit_save. She adds the scope-list OLNEs_toCommit and passes this list to the microflowORC_olne_save. She then adds a call to the FTN_olne_add_to_scope in order to put the changed OrderLine object from the page to the commit-list.

The resulting ACT microflow now looks like this:

image-20251124-124226.png