Pass by reference example

A Score Level 1

Can someone explain me any scenario where we can use pass by reference under subprocess ? Is pass by reference valid only for asynchronous type sub process?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I typically avoid "byReference" where possible.  On the majority of the projects I was on, it simply wasn't used.  The standard for those projects was to explicitly make the same variable an output of the subprocess.  This is good because it gives you very tight control over what gets it's value updated, and you can read the configuration of the subprocess node to figure out exactly what gets changed without having to scour the subprocess model to find it.

    I can think of a few instances where you'd want to pass by reference.  Imagine you had 2 simultaneous workflows.  You could have one in a subprocess and pass a "status" variable by reference.  You could park the parallel flow behind an AND gate waiting for a trigger by the referenced variable being changed.  That way you know the subprocess has gotten at least this far.  And you don't have to go through all the effort to build infrastructure for sending message from one PM to another, which I also hear is frightfully slow.  Each process could update the same status variable, and now the two could run in parallel while holding themselves back to avoid race conditions with each other.  I'm actually thinking I'd like to build a POC of that very thing now.

Reply
  • 0
    Certified Lead Developer

    I typically avoid "byReference" where possible.  On the majority of the projects I was on, it simply wasn't used.  The standard for those projects was to explicitly make the same variable an output of the subprocess.  This is good because it gives you very tight control over what gets it's value updated, and you can read the configuration of the subprocess node to figure out exactly what gets changed without having to scour the subprocess model to find it.

    I can think of a few instances where you'd want to pass by reference.  Imagine you had 2 simultaneous workflows.  You could have one in a subprocess and pass a "status" variable by reference.  You could park the parallel flow behind an AND gate waiting for a trigger by the referenced variable being changed.  That way you know the subprocess has gotten at least this far.  And you don't have to go through all the effort to build infrastructure for sending message from one PM to another, which I also hear is frightfully slow.  Each process could update the same status variable, and now the two could run in parallel while holding themselves back to avoid race conditions with each other.  I'm actually thinking I'd like to build a POC of that very thing now.

Children
No Data