Rules
There are rules to how the codes and the information they contain can be sequenced, acquired and replaced. These rules are known as hierarchy, referencing and overwriting.
Hierarchy in Coding
Hierarchy exists in a flowchart, determined by the sequence of its nodes and procedures. It is closely related with the concept of dependency whereby the information downstream depends on the information passed down from upstream. Hence, information has to be defined upstream first, before a downstream procedure can reference or overwrite the information.
Upstream
If element A is upstream in reference to element B, element A lies above element B in the procedure.
If node A is upstream in reference to node B, node A lies above node B in the flowchart.
Downstream
If element A is downstream in reference to element B, element A lies below element B in the procedure.
If node A is downstream in reference to node B, node A lies below node B in the flowchart.
Referencing
Referencing refers to accessing data that are created upstream in the same or previous nodes.
Referencing Within the Same Node
To access data created by upstream procedures in the same node, users can reference by its variables or attributes.
In the case of referencing by its attributes, users can
- run the query.Get function to access entity attributes
- reference global attributes directly or
- reference the default attributes directly.
Referencing Across Nodes
Nodes Connected in Series
To access data created by upstream nodes that are in series with the current node, users can reference by its attributes.
In the case of referencing by its attributes, users can
- run the query.Get function to access entity attributes
- reference global attributes directly or
Nodes Connected in Parallel
Users cannot acquare data from an node connected in parallel with the current node.
Overwriting
In programming, overwriting is the process of new values replacing old values when:
- A variable created downstream in the node shares the same name as a variable upstream.
- A modify function is used on a variable.
Overwriting helps users update variables and the values they contain; however bugs may occur when the users unintentionally overwrite older codes that he/she intends to keep. When this happens, there will be errors causing incorrect or unexpected results. Hence, if a user does not intend to overwrite, he/she should:
- Name a new variable differently from the variables upstream.
- Make a copy of the variable that he/she intends to keep, before using the copy as an argument input for the modify function.
See Common Misconceptions and Workflow: Hierarchy and Overwriting