A method and device for processing object-oriented business logic
Through edge set array and node type processing, the problems of business logic code complexity and changes in external conditions in object-oriented programming are solved, simplifying and stable business logic processing is achieved, and maintenance costs are reduced.
Patent Information
- Application Number
- CN202210264306.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-17
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2042-03-17
AI Technical Summary
In existing object-oriented programming, the business logic code is complex, and the calculation logic and control logic are mixed and nested, resulting in poor code readability and difficulty in maintenance. Changes in external conditions can easily lead to function output errors, making it difficult to effectively manage complex business logic.
Adopt the edge set array method, store business logic nodes and their relationships through vertex arrays and edge arrays, use the types of control nodes and calculation nodes to process business logic, and isolate external conditions through preset storage object conversion and edge value search to ensure The logic is stable and updates the edge set array when conditions change.
It simplifies complex business logic code, reduces maintenance costs, improves code stability and maintainability, and avoids the direct impact of changes in external conditions on business logic.
Smart Images

Figure CN114637492B
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development, and in particular to a method and device for processing object-oriented business logic. Background Art
[0002] As the business continues to expand, the business logic code written in the original object-oriented programming needs to be continuously added and modified, making the original business logic code logically complex and difficult to maintain. In particular, in the business logic code, the calculation logic and control logic are mixed and nested, resulting in poor code readability and difficulty in code maintenance.
[0003] Moreover, complex business logic usually relies on many input conditions, and these conditions are usually scattered inside various objects in the business logic, making it difficult to maintain. As long as the internal member variables of an object change, the output of the function may be wrong. Therefore, there is an urgent need for a good way to manage messy business logic code and reduce the cost of maintaining business logic code. Summary of the invention
[0004] In view of this, the present application provides a method and device for processing object-oriented business logic, which can simplify complex business logic codes and reduce the cost of maintaining business logic codes.
[0005] In a first aspect, the present application provides an object-oriented business logic processing method, the method is applied to an edge set array, the edge set array includes: a vertex array and an edge array; the vertex array stores each node of the business logic; each array element in the edge array includes a start point, an end point and an edge value of an edge; the method includes:
[0006] Taking out a first node from the vertex array, where the type of the first node is a control node or a computing node;
[0007] When the type of the first node is a control node, after converting the preset first storage object into a source object, the source object is input into the first node, and the first storage object is used to store the external conditions on which the business logic depends; according to the external conditions on which the business logic depends in the source object, a method corresponding to the first node is executed to obtain a first edge value corresponding to the first node; a second node with a starting point of the first node and an edge value equal to the first edge value is searched from the edge array, and the second node is the computing node;
[0008] Input the first storage object into the second node, and execute the method corresponding to the second node to obtain the second storage object according to the external conditions that the business logic in the first storage object depends on; determine whether the next node of the second node is empty, and when the next node of the second node is not empty, determine the type of the next node of the second node, until there is no edge in the edge array that is equal to the edge value of the next node of the second node;
[0009] When the type of the first node is a computing node, a preset first storage object is input into the first node; according to the external conditions on which the business logic in the first storage object depends, a method corresponding to the first node is executed to obtain a third storage object; and it is determined whether the next node of the first node is empty. When the next node of the first node is not empty, the type of the next node of the first node is determined until there is no edge in the edge array that is equal to the edge value of the next node of the first node.
[0010] Preferably, before taking out the first node from the vertex array, the method further comprises:
[0011] Create an edge set array, where the edge set array is used to store the relationship between each node in the business logic;
[0012] Creating a first storage object, where the first storage object is used to store external conditions that the business logic depends on;
[0013] Create control nodes and computing nodes according to the number of nodes in the business logic and the types of different nodes; save each control node and each computing node to the vertex array in the edge set array;
[0014] Create an edge according to the relationship between the nodes in the business logic; the starting point of the edge is a control node or a computing node, the end point of the edge is a control node or a computing node, and the edge value is the value of the edge connecting the control node to the computing node; save the edge to the edge array in the edge set array.
[0015] Preferably, the creating of control nodes and computing nodes according to the number of nodes in the business logic and different node types includes:
[0016] When the first node is a control node, a unary logic control node, a binary logic control node, or a multi-ary logic control node is created according to the service logic type of the first node.
[0017] Preferably, the method further comprises:
[0018] If the external conditions on which the business logic depends change, modify the data items stored in the first storage object;
[0019] If the method corresponding to the first node changes, modify the method corresponding to the first node;
[0020] If the business logic is updated, the edge set array is recreated according to the new business logic.
[0021] Preferably, the method further comprises:
[0022] When the first node is the last node in the vertex array, inputting the first storage object into the first node;
[0023] According to the external conditions on which the business logic in the first storage object depends, the method corresponding to the first node is executed to obtain the fourth storage object, thereby ending the determination of the type of the node in the business logic.
[0024] In a second aspect, the present application provides an object-oriented business logic processing device, the device is applied to an edge set array, the edge set array includes: a vertex array and an edge array; the vertex array stores each node of the business logic; each array element in the edge array includes a start point, an end point and an edge value of an edge; the device includes:
[0025] An acquisition module, used for taking out a first node from the vertex array, where the type of the first node is a control node or a computing node;
[0026] A first judgment module is used for, when the type of the first node is a control node, converting a preset first storage object into a source object, and inputting the source object into the first node, wherein the first storage object is used to store the external conditions on which the business logic depends; executing a method corresponding to the first node according to the external conditions on which the business logic depends in the source object, and obtaining a first edge value corresponding to the first node; searching from the edge array for a second node whose starting point is the first node and whose edge value is equal to the first edge value, wherein the second node is the computing node;
[0027] A second judgment module is used to input the first storage object into the second node, and execute the method corresponding to the second node to obtain the second storage object according to the external conditions that the business logic in the first storage object depends on; judge whether the next node of the second node is empty, and when the next node of the second node is not empty, judge the type of the next node of the second node, until there is no edge in the edge array that is equal to the edge value of the next node of the second node;
[0028] The third judgment module is used to input a preset first storage object into the first node when the type of the first node is a computing node; execute a method corresponding to the first node to obtain a third storage object according to external conditions that the business logic in the first storage object depends on; and judge whether the next node of the first node is empty. When the next node of the first node is not empty, judge the type of the next node of the first node until there is no edge in the edge array that is equal to the edge value of the next node of the first node.
[0029] Preferably, before taking out the first node from the vertex array, the device further comprises:
[0030] A first creation module is used to create an edge set array, where the edge set array is used to store the relationship between each node in the business logic;
[0031] A second creation module is used to create a first storage object, where the first storage object is used to store external conditions that the business logic depends on;
[0032] A third creation module is used to create control nodes and computing nodes according to the number of nodes in the business logic and the types of different nodes; and save each control node and each computing node to the vertex array in the edge set array;
[0033] The fourth creation module is used to create an edge according to the relationship between each node in the business logic; the starting point and end point of the edge are a control node or a computing node, the end point of the edge is a control node or a computing node, and the edge value is the value of the edge connecting the control node to the computing node; the edge is saved to the edge array in the edge set array.
[0034] Preferably, the third creation module includes:
[0035] The fifth creation module, when the first node is a control node, creates a unary logic control node, a binary logic control node, or a multi-ary logic control node according to the service logic type of the first node.
[0036] Preferably, it also includes:
[0037] a sixth creation module, configured to input the first storage object into the first node when the first node is the last node in the vertex array;
[0038] According to the external conditions on which the business logic in the first storage object depends, the method corresponding to the first node is executed to obtain the fourth storage object, thereby ending the determination of the type of the node in the business logic.
[0039] In a third aspect, the present application provides a storage medium having a program stored thereon, and the program implements any one of the above methods when executed by a processor.
[0040] It can be seen from the above technical scheme that the present application provides an object-oriented business logic processing method, which is applied to an edge set array, and the edge set array includes: a vertex array and an edge array; the vertex array stores various nodes of business logic; each array element in the edge array includes the starting point, end point and edge value of an edge; the method includes: taking out a first node from the vertex array, and the type of the first node is a control node or a computing node; when the type of the first node is a control node, converting a preset first storage object into a source object, and inputting the source object into the first node, and the first storage object is used to store the external conditions on which the business logic depends; according to the external conditions on which the business logic depends in the source object, executing the method corresponding to the first node, and obtaining the first edge value corresponding to the first node; searching from the edge array for a second node whose starting point is the first node and whose edge value is equal to the first edge value, and the second node is the one The computing node; input the first storage object into the second node, and execute the method corresponding to the second node to obtain the second storage object according to the external conditions on which the business logic in the first storage object depends; determine whether the next node of the second node is empty, and when the next node of the second node is not empty, determine the type of the next node of the second node, until there is no edge in the edge array that is equal to the edge value of the next node of the second node; when the type of the first node is a computing node, input the preset first storage object into the first node; according to the external conditions on which the business logic in the first storage object depends, execute the method corresponding to the first node to obtain the third storage object; determine whether the next node of the first node is empty, and when the next node of the first node is not empty, determine the type of the next node of the first node, until there is no edge in the edge array that is equal to the edge value of the next node of the first node. The embodiment of the present application can simplify complex business logic code and reduce the cost of maintaining business logic code. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1This is a flowchart of an object-oriented business logic processing method embodiment 1 disclosed in this application;
[0043] Figure 2 This is a flowchart of a second embodiment of an object-oriented business logic processing method disclosed in this application;
[0044] Figure 3 This is a schematic diagram showing an example of connecting control logic and calculation logic;
[0045] Figure 4 A schematic diagram showing examples of connections for different business logic types;
[0046] Figure 5 This is a schematic diagram of the structure of an object-oriented business logic processing device disclosed in this application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] like Figure 1 As shown, it is a flowchart of Example 1 of an object-oriented business logic processing method disclosed in the present application. The object-oriented business logic processing method provided in the embodiment of the present application is specifically applied to an edge set array, and the edge set array includes: a vertex array and an edge array; the vertex array stores each node of the business logic; each array element in the edge array includes the starting point, end point and edge value of an edge.
[0049] The object-oriented business logic processing method includes:
[0050] S101. Take out a first node from the vertex array, where the type of the first node is a control node or a computing node.
[0051] Specifically, a first node is taken out from the vertex array, and the first node may be a control (Predicate) node or a calculation (Reduce) node.
[0052] The vertex array and edge array are pre-created arrays. The vertex array stores each node of the business logic. Each array element of the edge array includes the start point, end point and edge value of an edge. The business logic is a function implemented by code. The specific process of creating the vertex array and edge array will be described in detail below and will not be repeated here.
[0053] S102. When the type of the first node is a control node, after converting a preset first storage object into a source object, the source object is input into the first node, and the first storage object is used to store the external conditions on which the business logic depends; according to the external conditions on which the business logic depends in the source object, a method corresponding to the first node is executed to obtain a first edge value corresponding to the first node; and a second node whose starting point is the first node and whose edge value is equal to the first edge value is searched from the edge array, and the second node is the computing node.
[0054] In an embodiment of the present application, when the type of the first node is a Predicate node, after converting the preset first storage (Store) object into a source (Source) object, the Source object is input into the first node. Among them, the first Store object is used to store the external conditions that the business logic depends on. In this way, before the business logic is executed, the external conditions that the business logic depends on are stored in the Store object. The subsequent execution of the business logic only depends on the Store object and no longer directly depends on the external conditions. Therefore, the execution of the business logic is not affected by unexpected changes in external conditions, which ensures the stability of the conditions for the execution of the business logic. Among them, the method corresponding to the node is the calculation logic code written according to the business logic requirements.
[0055] It should be noted that in order to avoid modifying the data status in the Store object in the Predicate node, only control logic such as conditional judgment is performed in the Predicate node, and no calculation logic is performed. Therefore, the Store object is converted into a Source object and passed into the Predicate node. The characteristic of the Source object is that it can only add and read data, but cannot remove and modify data, thereby ensuring that the control logic and calculation logic of the code are more stable.
[0056] After the Source object is input into the first node, the method corresponding to the first node is executed according to the external conditions that the business logic in the Source object depends on, and the first edge value corresponding to the first node is obtained.
[0057] Search the edge array for a second node whose starting point is the first node and whose edge value is equal to the first edge value. The second node is a calculation node. If an edge value equal to the first edge value is not found in the edge array, the determination of the type of the node is terminated.
[0058] S103. Input the first storage object into the second node, and execute the method corresponding to the second node to obtain the second storage object according to the external conditions that the business logic in the first storage object depends on; determine whether the next node of the second node is empty, and when the next node of the second node is not empty, determine the type of the next node of the second node, until there is no edge in the edge array that is equal to the edge value of the next node of the second node.
[0059] Specifically, after finding the second node corresponding to the first node in the edge array, input the first Store object into the second node, and execute the second node to obtain the second storage object according to the external conditions that the business logic in the first Store object depends on; determine whether the next node of the second node is empty, and when the next node of the second node is not empty, continue to determine the type of the next node of the second node, and when the edge array does not have an edge with the same edge value as the next node of the second node, end determining the type of the node.
[0060] S104. When the type of the first node is a computing node, input a preset first storage object into the first node; according to the external conditions on which the business logic in the first storage object depends, execute the method corresponding to the first node to obtain a third storage object; determine whether the next node of the first node is empty, and when the next node of the first node is not empty, determine the type of the next node of the first node, until there is no edge in the edge array that is equal to the edge value of the next node of the first node.
[0061] Specifically, when the type of the first node is a Reduce node, the first Store object is input into the first node, and according to the external conditions that the business logic in the first Store object depends on, the method corresponding to the first node is executed to obtain the third storage object; determine whether the next node of the first node is empty. When the next node of the first node is not empty, continue to determine the type of the next node of the first node. When the edge array does not have an edge with the same edge value as the next node of the second node, end determining the type of the node.
[0062] It should be noted that the first Store object is input into the Reduce node, and a new Store object is generated after the calculation is completed. All calculation results are stored in the returned Store object, and the side effects are isolated in the Store object, thereby ensuring that the control logic and calculation logic of the code are more stable and the code is easier to maintain.
[0063] It can be seen from the above technical scheme that the present application provides an object-oriented business logic processing method, which is applied to an edge set array, and the edge set array includes: a vertex array and an edge array; the vertex array stores various nodes of business logic; each array element in the edge array includes the starting point, end point and edge value of an edge; the method includes: taking out a first node from the vertex array, and the type of the first node is a control node or a computing node; when the type of the first node is a control node, converting a preset first storage object into a source object, and inputting the source object into the first node, and the first storage object is used to store the external conditions on which the business logic depends; according to the external conditions on which the business logic depends in the source object, executing the method corresponding to the first node, and obtaining the first edge value corresponding to the first node; searching from the edge array for a second node whose starting point is the first node and whose edge value is equal to the first edge value, and the second node is the one The computing node; input the first storage object into the second node, and execute the method corresponding to the second node to obtain the second storage object according to the external conditions on which the business logic in the first storage object depends; determine whether the next node of the second node is empty, and when the next node of the second node is not empty, determine the type of the next node of the second node, until there is no edge in the edge array that is equal to the edge value of the next node of the second node; when the type of the first node is a computing node, input the preset first storage object into the first node; according to the external conditions on which the business logic in the first storage object depends, execute the method corresponding to the first node to obtain the third storage object; determine whether the next node of the first node is empty, and when the next node of the first node is not empty, determine the type of the next node of the first node, until there is no edge in the edge array that is equal to the edge value of the next node of the first node. The embodiment of the present application can simplify complex business logic code and reduce the cost of maintaining business logic code.
[0064] Optionally, based on the above embodiment, refer to Figure 2 , before taking out the first node from the vertex array, further comprising:
[0065] S201. Create an edge set array, where the edge set array is used to store the relationship between nodes in the business logic.
[0066] Specifically, the graph structure composed of Predicate nodes and Reduce nodes is stored in the form of edge set array, which can be easily converted into a flow chart to realize the visualization of logical business code.
[0067] S202: Create a first storage object, where the first storage object is used to store external conditions that the business logic depends on.
[0068] Specifically, external conditions are conditions that business logic depends on. In object-oriented programming, external conditions can refer to member variables of classes and objects. For example, the method corresponding to object A requires member variable b1 of object B to participate in execution. At this time, for object A, member variable b1 of object B is an external condition of object A. The external conditions that business logic depends on are stored in the first Store object. This ensures that the external conditions on which subsequent control logic and calculation logic depend will not be affected by other businesses, and the side effects in object-oriented programming are isolated in the first Store object, thereby ensuring that the control logic and calculation logic of the code are more stable and the code is easier to maintain.
[0069] S203, creating control nodes and computing nodes according to the number of nodes in the business logic and different node types; and saving each control node and each computing node to a vertex array in the edge set array.
[0070] S204. Create an edge according to the relationship between the nodes in the business logic; the starting point of the edge is a control node or a computing node, the end point of the edge is a control node or a computing node, and the edge value is the value of the edge connecting the control node to the computing node; save the edge to the edge array in the edge set array.
[0071] like Figure 3 The figure shows an example diagram of the connection between control logic and calculation logic.
[0072] exist Figure 3 In the code, control nodes and computing nodes are created. The control nodes include: binary branch control logic (C1), multi-branch control logic (C2), and loop control logic (C3); the computing nodes include: 6 computing logics (from top to bottom, from left to right, they are R1, R2, R3, R4, R5, and R6).
[0073] To facilitate further understanding of the present application, taking C1 as an example, two edges C1-R1 and C1-R2 are created respectively, where the edge value of C1-R1 is 1 (yes) and the edge value of C1-R2 is 0 (no).
[0074] When the first node taken out is C1, the Store object is converted into a Source object and input into the C1 node. The C1 node reads the Source object and executes the method corresponding to the C1 node. The result is "yes" or "no", that is, the edge value is 1 or 0.
[0075] When the edge value is 1, it matches the C1-R1 edge, and when the edge value is 0, it matches the C1-R2 edge, and the next node can be obtained as R1 or R2, until there is no edge in the edge array with the same edge value as the next node of the node. It can be seen that this application supports declaring the graph structure before execution, so that the graph structure can be cached in memory without repeated creation, which speeds up code execution.
[0076] In the embodiment of the present application, through the combination of Source objects, Store objects, Predicate nodes, and Reduce nodes, the business logic code can be more clearly reflected, thereby improving the development efficiency and maintainability of the business logic code, and improving the overall software development and maintenance efficiency.
[0077] In the embodiment of the present application, since the nodes in the business logic and the relationships between the nodes are constructed in a graph manner, and the external conditions on which the business logic depends are stored in the first Store object, nested judgment logic and calculation logic are avoided, the code is easier to maintain, and the code development efficiency is improved.
[0078] Optionally, based on any of the foregoing embodiments, the step of creating a control node and a computing node according to the number of nodes in the business logic and different node types includes:
[0079] When the first node is a control node, a unary logic control node, a binary logic control node, or a multi-ary logic control node is created according to the service logic type of the first node.
[0080] Specifically, in the embodiment of the present application, when the first node is a judgment node, a Predicate node is created, and according to the business logic type of the first node, a unary (only one branch) logic Predicate node, a binary logic (two branches) Predicate node, and a multi-element (multiple branches) logic Predicate node are created.
[0081] like Figure 4 The following are example diagrams of connections of different logic types.
[0082] Optionally, based on any of the above embodiments, the method further includes:
[0083] If the external conditions on which the business logic depends change, modify the data items stored in the first storage object;
[0084] If the method corresponding to the first node changes, modify the method corresponding to the first node;
[0085] If the business logic is updated, the edge set array is recreated according to the new business logic.
[0086] Specifically, in the embodiment of the present application, when the external conditions on which the business logic depends change, the data items stored in the first Store object are added or modified.
[0087] When the methods corresponding to the Predicate node and the Reduce node change, there is no need to change the structure of the graph, only the methods corresponding to the Predicate node and the Reduce node need to be modified.
[0088] If the business logic is updated, the business logic can be reorganized, and then new Predicate nodes and Reduce nodes can be created according to the new business logic, and then the upper and lower nodes can be connected. It can be seen that in the embodiment of the present application, the node is the basic unit, which can better maintain the integrity of the internal logic of the node, thereby improving the maintainability of the code.
[0089] Optionally, based on any of the above embodiments, the method further includes:
[0090] When the first node is the last node in the vertex array, inputting the first storage object into the first node;
[0091] According to the external conditions on which the business logic in the first storage object depends, the method corresponding to the first node is executed to obtain the fourth storage object, thereby ending the determination of the type of the node in the business logic.
[0092] Specifically, when the first node taken out is the last node in the vertex array, the first Store object is input into the first node, and according to the external conditions that the business logic in the first Store object depends on, the method corresponding to the first node is executed to obtain the fourth Store object. Since the first node taken out is the last node in the vertex array, the judgment of the type of node in the business logic is ended.
[0093] like Figure 5 FIG. 1 is a schematic diagram of a structure of a device for simplifying object-oriented business logic disclosed in the present application, comprising:
[0094] An acquisition module 100 is used to take out a first node from the vertex array, where the type of the first node is a control node or a computing node;
[0095] The first judgment module 200 is used for, when the type of the first node is a control node, converting a preset first storage object into a source object, and inputting the source object into the first node, wherein the first storage object is used to store the external conditions on which the business logic depends; executing a method corresponding to the first node according to the external conditions on which the business logic depends in the source object, and obtaining a first edge value corresponding to the first node; searching from the edge array for a second node whose starting point is the first node and whose edge value is equal to the first edge value, wherein the second node is the computing node;
[0096] The second judgment module 300 is used to input the first storage object into the second node, and execute the method corresponding to the second node to obtain the second storage object according to the external conditions that the business logic in the first storage object depends on; judge whether the next node of the second node is empty, and when the next node of the second node is not empty, judge the type of the next node of the second node, until there is no edge in the edge array that is equal to the edge value of the next node of the second node;
[0097] The third judgment module 400 is used to input a preset first storage object into the first node when the type of the first node is a computing node; execute a method corresponding to the first node to obtain a third storage object according to external conditions that the business logic in the first storage object depends on; and judge whether the next node of the first node is empty. When the next node of the first node is not empty, judge the type of the next node of the first node until there is no edge in the edge array that is equal to the edge value of the next node of the first node.
[0098] Optionally, before taking out the first node from the vertex array, the device further includes:
[0099] A first creation module is used to create an edge set array, where the edge set array is used to store the relationship between each node in the business logic;
[0100] A second creation module is used to create a first storage object, where the first storage object is used to store external conditions that the business logic depends on;
[0101] A third creation module is used to create control nodes and computing nodes according to the number of nodes in the business logic and the types of different nodes; and save each control node and each computing node to the vertex array in the edge set array;
[0102] The fourth creation module is used to create an edge according to the relationship between each node in the business logic; the starting point and end point of the edge are a control node or a computing node, the end point of the edge is a control node or a computing node, and the edge value is the value of the edge connecting the control node to the computing node; the edge is saved to the edge array in the edge set array.
[0103] Optionally, the third creation module includes:
[0104] The fifth creation module is used to create a unary logic control node, a binary logic control node, or a multi-ary logic control node according to the service logic type of the first node when the first node is a control node.
[0105] Optionally, the device further comprises:
[0106] a sixth creation module, configured to input the first storage object into the first node when the first node is the last node in the vertex array;
[0107] According to the external conditions on which the business logic in the first storage object depends, the method corresponding to the first node is executed to obtain the fourth storage object, thereby ending the determination of the type of the node in the business logic.
[0108] An embodiment of the present application provides a storage medium on which a program is stored. When the program is executed by a processor, the method for simplifying object-oriented business logic described in the above embodiment is implemented.
[0109] In summary, the present application provides an object-oriented business logic processing method, the method is applied to an edge set array, the edge set array includes: a vertex array and an edge array; the vertex array stores various nodes of business logic; each array element in the edge array includes the starting point, end point and edge value of an edge; the method includes: taking out a first node from the vertex array, the type of the first node is a control node or a computing node; when the type of the first node is a control node, converting a preset first storage object into a source object, and inputting the source object into the first node, the first storage object is used to store the external conditions on which the business logic depends; according to the external conditions on which the business logic depends in the source object, executing the method corresponding to the first node, and obtaining the first edge value corresponding to the first node; searching from the edge array for a second node whose starting point is the first node and whose edge value is equal to the first edge value, the second node being the computing node point; input the first storage object into the second node, and execute the method corresponding to the second node to obtain the second storage object according to the external conditions on which the business logic in the first storage object depends; determine whether the next node of the second node is empty, and when the next node of the second node is not empty, determine the type of the next node of the second node, until there is no edge in the edge array that is equal to the edge value of the next node of the second node; when the type of the first node is a computing node, input the preset first storage object into the first node; according to the external conditions on which the business logic in the first storage object depends, execute the method corresponding to the first node to obtain the third storage object; determine whether the next node of the first node is empty, and when the next node of the first node is not empty, determine the type of the next node of the first node, until there is no edge in the edge array that is equal to the edge value of the next node of the first node. The embodiment of the present application can simplify complex business logic code and reduce the cost of maintaining business logic code.
[0110] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0111] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0112] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0113] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for processing object-oriented business logic, characterized in that: The method is applied to an edge set array, the edge set array includes: a vertex array and an edge array; the vertex array stores various nodes of business logic; each array element in the edge array includes a starting point, an end point and an edge value of an edge; The method comprises: Taking out a first node from the vertex array, where the type of the first node is a control node or a computing node; When the type of the first node is a control node, after converting the preset first storage object into a source object, the source object is input into the first node, and the first storage object is used to store the external conditions on which the business logic depends; according to the external conditions on which the business logic depends in the source object, a method corresponding to the first node is executed to obtain a first edge value corresponding to the first node; a second node with a starting point of the first node and an edge value equal to the first edge value is searched from the edge array, and the second node is the computing node; Input the first storage object into the second node, and execute the method corresponding to the second node to obtain the second storage object according to the external conditions that the business logic in the first storage object depends on; determine whether the next node of the second node is empty, and when the next node of the second node is not empty, determine the type of the next node of the second node, until there is no edge in the edge array that is equal to the edge value of the next node of the second node; When the type of the first node is a computing node, a preset first storage object is input into the first node; according to the external conditions on which the business logic in the first storage object depends, a method corresponding to the first node is executed to obtain a third storage object; and it is determined whether the next node of the first node is empty. When the next node of the first node is not empty, the type of the next node of the first node is determined until there is no edge in the edge array that is equal to the edge value of the next node of the first node.
2. The method according to claim 1, characterized in that Before taking out the first node from the vertex array, the method further includes: Create an edge set array, where the edge set array is used to store the relationship between each node in the business logic; Creating a first storage object, where the first storage object is used to store external conditions that the business logic depends on; Create control nodes and computing nodes according to the number of nodes in the business logic and the types of different nodes; save each control node and each computing node to the vertex array in the edge set array; Create an edge according to the relationship between the nodes in the business logic; the starting point of the edge is a control node or a computing node, the end point of the edge is a control node or a computing node, and the edge value is the value of the edge connecting the control node to the computing node; save the edge to the edge array in the edge set array.
3. The method according to claim 2, characterized in that The creating of control nodes and computing nodes according to the number of nodes in the business logic and different node types includes: When the first node is a control node, a unary logic control node, a binary logic control node, or a multi-ary logic control node is created according to the service logic type of the first node.
4. The method according to claim 1, characterized in that: The method further comprises: If the external conditions on which the business logic depends change, modify the data items stored in the first storage object; If the method corresponding to the first node changes, modify the method corresponding to the first node; If the business logic is updated, the edge set array is recreated according to the new business logic.
5. The method according to claim 1, characterized in that: The method further comprises: When the first node is the last node in the vertex array, inputting the first storage object into the first node; According to the external conditions on which the business logic in the first storage object depends, the method corresponding to the first node is executed to obtain the fourth storage object, thereby ending the determination of the type of the node in the business logic.
6. A processing device for object-oriented business logic, characterized in that: The device is applied to an edge set array, the edge set array includes: a vertex array and an edge array; the vertex array stores various nodes of business logic; each array element in the edge array includes a starting point, an end point and an edge value of an edge; The device comprises: An acquisition module, used for taking out a first node from the vertex array, where the type of the first node is a control node or a computing node; A first judgment module is used for, when the type of the first node is a control node, converting a preset first storage object into a source object, and inputting the source object into the first node, wherein the first storage object is used to store the external conditions on which the business logic depends; executing a method corresponding to the first node according to the external conditions on which the business logic depends in the source object, and obtaining a first edge value corresponding to the first node; searching from the edge array for a second node whose starting point is the first node and whose edge value is equal to the first edge value, wherein the second node is the computing node; A second judgment module is used to input the first storage object into the second node, and execute the method corresponding to the second node to obtain the second storage object according to the external conditions that the business logic in the first storage object depends on; judge whether the next node of the second node is empty, and when the next node of the second node is not empty, judge the type of the next node of the second node, until there is no edge in the edge array that is equal to the edge value of the next node of the second node; The third judgment module is used to input a preset first storage object into the first node when the type of the first node is a computing node; execute a method corresponding to the first node to obtain a third storage object according to external conditions that the business logic in the first storage object depends on; and judge whether the next node of the first node is empty. When the next node of the first node is not empty, judge the type of the next node of the first node until there is no edge in the edge array that is equal to the edge value of the next node of the first node.
7. The device according to claim 6, characterized in that Before taking out the first node from the vertex array, the device further includes: A first creation module is used to create an edge set array, where the edge set array is used to store the relationship between each node in the business logic; A second creation module is used to create a first storage object, where the first storage object is used to store external conditions that the business logic depends on; A third creation module is used to create control nodes and computing nodes according to the number of nodes in the business logic and the types of different nodes; and save each control node and each computing node to the vertex array in the edge set array; The fourth creation module is used to create an edge according to the relationship between each node in the business logic; the starting point and end point of the edge are a control node or a computing node, the end point of the edge is a control node or a computing node, and the edge value is the value of the edge connecting the control node to the computing node; the edge is saved to the edge array in the edge set array.
8. The device according to claim 7, characterized in that The third creation module comprises: The fifth creation module, when the first node is a control node, creates a unary logic control node, a binary logic control node, or a multi-ary logic control node according to the service logic type of the first node.
9. The device according to claim 6, characterized in that Also includes: a sixth creation module, configured to input the first storage object into the first node when the first node is the last node in the vertex array; According to the external conditions on which the business logic in the first storage object depends, the method corresponding to the first node is executed to obtain the fourth storage object, thereby ending the determination of the type of the node in the business logic.
10. A storage medium, characterized in that: The storage medium stores a program, and when the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
