Project Refactoring
Image/Model
When modifying, ensure that no nodes using the Image/Model are overlooked.
Tip
Make good use of global search.
Pipeline
Sub Node
Here, nodes with the deprecated is_sub value set to true are referred to as sub nodes.
Refactoring sub nodes involves the following steps:
- Determine whether the
sub nodeis of the lowest priority in thenextlist of the current node (i.e., directly moving it to theinterruptlist of the current node has no impact on the actual effect). - If the
sub nodeis not of the lowest priority, the refactoring method is to add thenextandinterruptof the current node to thesub node(if the originalnextandinterruptare empty, this can be done directly; otherwise, consider potential conflicts). If thesub nodeis of the lowest priority, the refactoring method is to directly move it to theinterruptof the current node. - If the
sub nodeis not of the lowest priority and the changes in step 2 cause conflicts, reconsider the task logic. - Remove the
is_subattribute from thesub node.
Warning
All the above changes must consider all nodes using the sub node. Do not overlook any!
Here is an example, assuming that the current node before reconstruction is as follows:
"Start": {
"next": [ "Sub_A", "B", "Sub_C", "D" ]
// Here we assume that Sub_A can be judged last, and Sub_C must be after B and before D.
}
It can be changed to the following form:
"Start": {
"next": [ "B", "C", "D" ],
"interrupt": [ "A" ]
},
"A": {
"next": A.nextlist // The original next list of node A
},
"B": {
"next": B.nextlist
},
"C": {
"next": [ "B", "C", "D" ] + C.nextlist, // The next list of the Start node is merged with the original list of the C node, paying attention to the order and other issues
"interrupt": [ "A" ]
},
"D": {
"next": D.nextlist
}
Other Nodes
Next, refactor other nodes based on their specific purposes.
Standardizing Node Names
If the goal is merely to standardize node names, use VSCode’s global search and replace functionality.
However, ensure that replacements include double quotes to avoid modifying other nodes containing the node name.
Simplifying Task Flows and Reducing Coupling
First, read Node Connections and refactor towards adhering to connection principles.
Some nodes can be moved to the interrupt of the ancestor node of the current node.
After moving, remove unnecessary next nodes to avoid continuing the main task chain in the interrupt, which could cause errors in subsequent tasks and return to the ancestor node.
Merging Nodes with Similar Functions
If multiple nodes perform the same function, consider merging them into a single node.
Steps:
- Before merging, check whether there are unrelated nodes in the
nextof the node. If so, separate them first. - During merging, all nodes should adopt the same standardized name.
- After merging, check whether the node’s position in all tasks is correct. For example, ensure nodes that should be in the
interruptare not in the main task chain’snextsection.