A method of generating logic code
By automatically generating logic code using the JSON description language, the problem of code quality and security being affected by technical personnel in JAVA software development is solved, achieving efficient and secure code generation.
Patent Information
- Application Number
- CN202211344019.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2042-10-31
AI Technical Summary
Current Java software development relies on technical personnel to write logic code, which makes code quality, efficiency, and security highly dependent on technical skills and experience. Furthermore, the learning curve is steep, making it difficult to guarantee code performance and security.
The program automatically generates logic code, uses the general-purpose JSON language to describe the programming syntax, and automatically executes the generated logic code, reducing reliance on technical personnel.
It enables the generation of high-performance, highly secure, and highly compatible logic code without relying on technical personnel's Java programming skills, reducing the requirements for learning and understanding complex ecosystems.
Smart Images

Figure CN116149622B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of software development, in particular to a method for generating logic code. BACKGROUND
[0002] At present, in the field of software system development, most IT software companies basically take JAVA technology as the benchmark, and form a large number of technical standards and platform frameworks. The ecological system related to JAVA field and platform is increasingly large, which leads to the increasingly strict requirement for the depth of JAVA technology learning and the breadth of technology ecological understanding of professional technical personnel, so that the technical personnel writing JAVA logic code not only need to learn the JAVA itself syntax in depth, but also need to learn a large number of technical standards and platform frameworks formed with JAVA technology as the core. Simply speaking, in addition to understanding the JAVA technology programming syntax, the technical personnel also need to understand a large amount of programming knowledge related to JAVA technology ecology, such as database, middleware, third-party interface API, etc., which undoubtedly greatly improves the threshold of writing JAVA logic code. Moreover, due to the large number of standards and platforms, the learning and understanding degree of technical personnel on various standards and platforms is different, which also makes the quality, efficiency, safety, etc. of the logic code written by different technical personnel cannot be fully guaranteed.
[0003] In general, in the existing JAVA software development technology, the following disadvantages exist: 1. The logic code can only be written by JAVA technical personnel, and the business ability of the technical personnel is required to be high; 2. The quality of the code written by different JAVA technical personnel is uneven; the complexity of the implementation logic code is proportional to the technical ability and experience of the professional technical personnel; that is, the quality, efficiency, safety, etc. of the logic code written by the related professional technical personnel are greatly influenced by the technical level, personal experience, etc., and the performance of the logic code cannot be effectively guaranteed.
[0004] Therefore, the present application aims to provide a method for generating logic code, which can automatically generate logic code through a program, reduce the dependence on manual work, and thus does not need to care about the proficiency of JAVA programming language mastered by technical personnel and the understanding degree of related standards and platforms, and can effectively guarantee the performance and safety of the logic code. SUMMARY
[0005] The present application aims to provide a method for generating logic code, which can automatically generate logic code through a program, reduce the dependence on manual work, and thus does not need to care about the proficiency of JAVA programming language mastered by technical personnel and the understanding degree of related standards and platforms, and can effectively guarantee the performance and safety of the logic code.
[0006] The technical solution of the present application is: a method for generating logic code, which is automatically executed by a program, comprising the following steps:
[0007] S1, selecting a trigger point needing to call a logic code; and recording trigger point related description information in a general description language;
[0008] S2, according to requirement logic analysis, predicting the syntax that will appear in the logic, and combing the order and relationship thereof;
[0009] S3, according to the order determined in the previous step, finding the corresponding relationship between the syntax and the key value of the general description language in turn;
[0010] S4, filling the key value pair of the corresponding syntax into the general description language, and making the parent-child and correlation relationship of each key value;
[0011] S5, submitting the parsing engine for syntax analysis, and generating the corresponding logic code.
[0012] Further, the general description language is JSON (JavaScript Object Notation is a lightweight data exchange format, easy to read and write by people, and can exchange data between multiple languages), and the key value of JSON includes but is not limited to variable declaration, variable call, loop, judgment, type conversion, numerical calculation, database operation (addition, deletion, modification and query), multi-table database association, subquery, aggregation query, grouping query, interface call, etc.
[0013] Further, in the step S1, the trigger point is set before or after the execution of each function code in the software architecture service layer.
[0014] Further, in step S1, the description information includes the type, name and other related description key value pairs of the logic code trigger point.
[0015] Further, in step S4, according to the actual business requirement logic, find the key value corresponding table corresponding to each requirement logic, and fill in the actual configuration attribute, adjust the logic level and the upper and lower levels and the correlation relationship.
[0016] Further, in step S5, according to the level and the upper and lower relationship of each logic, the corresponding logic code is generated in the function trigger point of the given service layer.
[0017] Compared with the prior art, the beneficial effects of the present application are: the present application can automatically generate logic code through software program, without relying on JAVA technical personnel, and thus without worrying about the proficiency of JAVA technical personnel in JAVA programming language and whether the experience is rich, the performance of the generated logic code is good, safe and high in compatibility.
[0018] The application summarizes the programming syntax by deeply understanding JAVA technology and its ecological tools and platform. The programming syntax is described again by using general description language (JSON), each JSON key value represents a syntax. The characteristics of JSON itself can be used to express the cooperation and mutual call, association and cooperation between each programming language. The general description language (JSON) is used for unified analysis, and the JAVA logic code with standard, norm, safety and high compatibility is generated. BRIEF DESCRIPTION OF DRAWINGS
[0019] Figure 1 is a flowchart of the application; DETAILED DESCRIPTION
[0020] The application will be further described in detail in combination with specific embodiments, and the methods or functional components not specifically described in the embodiments are prior art.
[0021] Embodiment 1
[0022] As shown in the flow of the method for generating logic code in the embodiment, the method comprises the following steps: Figure 1
[0023] S1, selecting a trigger point requiring to call logic code; and recording trigger point related description information in a general description language;
[0024] In the existing JAVA popular framework system, according to the software architecture layering idea, it is usually divided into the following levels: control layer, model layer and service layer. According to the requirements in the coding specification, the business logic code in the software system is required to be written in the service layer. At the same time, the create\update\delete\query function (also called class method) in the service layer exists, that is, the function for realizing CURD (add, delete, modify and query), the above method generally only operates on a single data model. Once the logic of querying or operating on other data models is required, the business logic code needs to be written in the above function; therefore, the trigger point in the embodiment is set before or after the execution of the function code in the service layer.
[0025] S2, according to the demand logic analysis and prediction, the syntax appearing in the logic is found, and the order and relationship are sorted out;
[0026] S3, according to the order determined in the above step, the corresponding relationship between the syntax and the general description language key value is found;
[0027] S4, fill the key-value pairs corresponding to the syntax into the general description language, and make the parent-child and association relationship of each key-value; find the key-value pair corresponding table corresponding to each requirement logic according to the actual business requirement logic, such as defining variables, operating variables, judging, looping, querying data, deleting data, etc., and fill in the actual configuration attributes according to the JSON data example, and the logical level and logical upper and lower levels, association relationship can be adjusted;
[0028] S5, submit the parsing engine for syntax analysis to generate corresponding logic code.
[0029] In this embodiment, the general description language logic key-value table is shown in the following table:
[0030] Table 1
[0031] The JSON data example is as follows:
[0032]
[0033]
[0034] The above is only some embodiments of the present application and is not used to limit the present application. For those skilled in the art, the present application can have combinations and variations of the foregoing various technical features, and those skilled in the art can make improvements, variations, equivalent replacements of the present application without departing from the spirit and scope of the present application, or use the structure or method of the present application in other fields to achieve the same effect, which all belong to the protection scope of the present application.
Claims
1. A method for generating logic code, characterized in that, Includes the following steps: S1. Select the point before or after the execution of each function code in the software architecture service layer as the trigger point for calling the logic code. The function code includes the create function, update function, delete function, and query function. Record the relevant description information of the trigger point in a general description language. The description information includes key-value pairs describing the type and name of the logic code trigger point. S2. Based on the business requirements logic analysis, predict the programming syntax that will appear in the logic. The programming syntax includes variable declaration, variable calling, loop, judgment, database operation, multi-table database association, interface call, and sort out the execution order and logical relationship of the programming syntax. S3. Based on the execution order determined in the previous step, find the unique correspondence between each programming syntax and the key-value pair of the general description language, where the general description language is JSON; S4. Fill the key-value pairs corresponding to the programming syntax into the JSON. Adjust the parent-child relationship and association relationship of each key-value pair according to the actual business needs logic. The parent-child relationship is implemented through the children field of the JSON and is used to express the nested execution order of the business logic. The execution order includes condition judgment within the loop body and nested sorting of database queries. S5. Submit the parsing engine to perform syntax parsing on the JSON. Based on the parent-child relationship, association relationship, and unique correspondence between programming syntax and key-value pairs, generate corresponding logic code in the predetermined function trigger points of the service layer.
2. The method for generating logic code according to claim 1, characterized in that: The JSON key-value pairs include variable declaration key-value pairs, variable call key-value pairs, loop key-value pairs, conditional key-value pairs, database operation key-value pairs, multi-table database join key-value pairs, and API call key-value pairs. Each key-value pair corresponds to a unique programming syntax.
3. The method for generating logic code according to claim 1, characterized in that: In step S4, based on the actual business requirement logic, the key-value mapping table corresponding to each requirement logic is found, and the actual configuration attributes are filled in. The configuration attributes include database connection information, SQL script information, and interface address information.
4. The method for generating logic code according to claim 1, characterized in that: In step S5, when the parsing engine parses the JSON, it first identifies the type and name key-value pairs of the trigger point to determine the insertion position of the logic code. Then, it parses the execution order of the programming syntax according to the parent-child relationship and association relationship of the key-value pairs, and finally generates the corresponding logic code.
5. The method for generating logic code according to claim 1, characterized in that: When sorting out the logical relationships of programming syntax in step S2, it includes determining the dependency and exclusion relationships between syntaxes; wherein, determining the dependency relationship includes database query syntax depending on variable call syntax, and determining the exclusion relationship includes two mutually exclusive condition judgment syntaxes.
6. The method for generating logic code according to claim 1, characterized in that: The generated logic code is in Java and is compatible with the Spring framework, allowing it to be directly integrated into the service layer of e-government systems or enterprise management systems.
Citation Information
Patent Citations
A processing method and device for converting a page application into a native application
CN109814866A
Method of automatic generation of source for business process automation
KR1020150060174A