A software engineering code generation method and device

By pre-written project skeleton templates and functional module templates, and using the cloud service platform to generate unified development code, the problem of lack of standardized development specifications in the existing technology is solved, and the development efficiency and code reuse ability is improved.

CN114691120BActive Publication Date: 2025-06-06GUANGDONG FLYING ENTERPRISE INTERNET TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011560788.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-25
Publication Date
2025-06-06
Estimated Expiration
2040-12-25

AI Technical Summary

Technical Problem

The lack of standardized development specifications for existing software project development coding, resulting in improper framework selection, high time cost for development process, and lack of a mechanism for code reuse.

Method used

Provides a software engineering code generation method, through the pre-writing of project skeleton templates and functional module templates, and the pre-creation of data tables, the cloud service platform generates unified development code, and automatically decompresses and copys to the working directory.

Benefits of technology

A unified development specification has been achieved, the risks brought about by improper framework selection have been avoided, and the development timeliness has been improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691120B_ABST
    Figure CN114691120B_ABST
Patent Text Reader

Abstract

The embodiment of the present application relates to a method and device for generating software engineering code, and the method includes a project skeleton code generation method and a function module code generation method. Through the pre-writing of the project skeleton template and the function module template and the pre-creation of the data table, after the developer sends the project creation instruction and the function module code generation instruction through the client tool, the cloud service platform renders the project skeleton template according to the project creation instruction and the function module code generation instruction and renders the data table based on the function module template to obtain the code, and automatically decompresses and copies the code to the working directory, thereby unifying the development specifications and improving the development timeliness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating software engineering codes. Background Art

[0002] The existing software project development coding is done by the technical leader of the development team who conducts a technical evaluation based on the characteristics of the project and then conducts a team review to determine the final selection. After the new technology is selected, it is necessary to train the team. The training methods and content are temporary and non-standard. During the development process, code reuse is almost entirely dependent on personal experience or reuse is not considered unconsciously. When problems are discovered temporarily, solutions and technical implementations are considered temporarily.

[0003] However, there are many available technical frameworks to choose from, and the cost of selection or trial and error is high. Different people have different processing habits, which leads to different solutions. There is a lack of standardized development specifications, which leads to high time costs in the development process. Summary of the invention

[0004] Based on this, the purpose of the present invention is to provide a software engineering code generation method and device, which has the advantages of avoiding the risks brought by improper framework selection, providing unified standardized development specifications, and improving development timeliness.

[0005] In order to achieve the above object, the first aspect of the present invention is to provide a software engineering code generation method, including a project skeleton code generation method and a function module code generation method;

[0006] The project skeleton code generation method comprises:

[0007] The client tool sends a project creation instruction to the cloud service platform, wherein the cloud service platform stores a pre-written project skeleton template;

[0008] The cloud service platform matches the project skeleton template according to the project creation instruction, and renders the matched project skeleton template to obtain the project skeleton code;

[0009] Determine whether the project skeleton template is rendered successfully;

[0010] If the project skeleton template is rendered successfully, the first status code and the project skeleton code are compressed and packaged into a first compressed package, and returned to the client tool;

[0011] The client tool receives the first compressed package returned by the cloud service platform, and analyzes the first status code;

[0012] Determine whether the first status code response is successful;

[0013] If the first status code response is success, decompress the first compressed package into a local working directory;

[0014] The function module code generation method comprises:

[0015] Creating a function module template and a data table on the cloud service platform;

[0016] The client tool sends a function module code generation instruction to the cloud service platform;

[0017] The cloud service platform searches the data table according to the function module code generation instruction;

[0018] Determine whether there is a data table corresponding to the function module code generation instruction;

[0019] If there is a corresponding data table, the corresponding data table is rendered according to the function module template to generate the function module code;

[0020] Determine whether the functional module template is rendered successfully;

[0021] If the function module template is rendered successfully, compress and package the second status code and the function module code into a second compressed package, and return it to the client tool;

[0022] The client tool receives the second compressed package returned by the cloud service platform, and analyzes the second status code;

[0023] Determine whether the second status code responds to success;

[0024] If the second status code response is success, the second compressed package is decompressed to the project source code directory under the local directory.

[0025] Furthermore, the project creation instruction includes a project name and a project type identification code, and the cloud service platform matches the project skeleton template according to the project type identification code.

[0026] Furthermore, the function module code generation instruction includes a project name and a data table name, and the cloud service platform searches for the data table according to the data table name.

[0027] Furthermore, the cloud service platform receives the project creation instruction, and when the project type identification code is represented as backend or big data, the project name is converted into lowercase characters and used as the database name and the account name for logging into the database, and an irregular password of no less than 8 digits is randomly generated to create the database.

[0028] Furthermore, the database name, account name and password are encrypted and saved in a resource allocation table, and the cloud service platform performs resource allocation on the resource allocation table.

[0029] Furthermore, the Nacos interface in the resource allocation table is requested to create a service configuration, and the account and password of the database are written into the development and test namespaces.

[0030] Furthermore, the project skeleton template includes front-end, back-end, big data and mini-program skeleton templates.

[0031] Furthermore, the functional module code includes control class, logic class, data class and data operation code.

[0032] A second aspect of the present invention provides a software engineering code generation device, including a project skeleton code generation device and a function module code generation device;

[0033] The project skeleton code generating device comprises:

[0034] A project instruction creation unit, wherein the client tool sends a project creation instruction to a cloud service platform, wherein the cloud service platform stores a pre-written project skeleton template;

[0035] A project skeleton code generating unit, wherein the cloud service platform matches the project skeleton template according to the project creation instruction, and renders the matched project skeleton template to obtain a project skeleton code;

[0036] A first judging unit, judging whether the project skeleton template is rendered successfully;

[0037] The project skeleton code downloading unit compresses and packages the first status code and the project skeleton code into a first compressed package if the project skeleton template is rendered successfully, and returns the first compressed package to the client tool;

[0038] A first status code analysis unit, wherein the client tool receives the first compressed package returned by the cloud service platform and analyzes the first status code;

[0039] A second judging unit, judging whether the first status code response is successful;

[0040] A first decompression unit, if the first status code response is success, decompressing the first compressed package into a local working directory;

[0041] The functional module code generating device comprises:

[0042] A template and data table creation unit, which creates function module templates and data tables on the cloud service platform;

[0043] An instruction sending unit, wherein the client tool sends a function module code generation instruction to the cloud service platform;

[0044] A data table search unit, wherein the cloud service platform searches the data table according to the function module code generation instruction;

[0045] A third judgment unit is used to judge whether there is a data table corresponding to the function module code generation instruction;

[0046] The function module code generating unit renders the corresponding data table according to the function module template to generate the function module code if there is a corresponding data table;

[0047] A fourth judgment unit, judging whether the functional module template is rendered successfully;

[0048] The function module code downloading unit compresses and packages the second status code and the function module code into a second compressed package if the function module template is rendered successfully, and returns the second compressed package to the client tool;

[0049] A second status code analysis unit, wherein the client tool receives the second compressed package returned by the cloud service platform and analyzes the second status code;

[0050] A fifth judging unit, judging whether the second status code is responded as successful;

[0051] The second decompression unit decompresses the second compressed package to the project source code directory under the local directory if the second status code response is successful.

[0052] Compared with the prior art, the beneficial effects of the utility model are as follows: the present invention provides a software engineering code generation method and device, through the pre-writing of the project skeleton template and the function module template and the pre-creation of the data table, after the developer sends the project creation instruction and the function module code generation instruction through the client tool, the cloud service platform renders the project skeleton template according to the project creation instruction and the function module code generation instruction and renders the data table based on the function module template to obtain the code, and automatically decompresses the code and copies it to the working directory, thereby unifying the development specifications and improving the development timeliness. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 It is a flowchart of the method for generating the project skeleton code of the present invention;

[0054] Figure 2 It is a flowchart of the method for generating function module code of the present invention;

[0055] Figure 3 It is a structural block diagram of a device for generating a skeleton code of a project of the present invention;

[0056] Figure 4 It is a structural block diagram of the functional module code generation device of the present invention. DETAILED DESCRIPTION

[0057] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings.

[0058] See also Figure 1 and Figure 2 The embodiment of the present invention provides a software engineering code generation method including a project skeleton code generation method and a function module code generation method.

[0059] The project skeleton code generation method includes the following steps:

[0060] S101. The client tool sends a project creation instruction to the cloud service platform, wherein the cloud service platform stores a pre-written project skeleton template.

[0061] The project skeleton is a standard engineering layout, including registration and discovery access, configuration center data access, unit testing capabilities, service startup, service stop, packaging scripts, deployment configuration scripts and other capabilities, which will be adjusted or increased or decreased with the continuous evolution of technology. In this embodiment, a dedicated person is responsible for maintaining the project skeleton and submitting it to the designated Git code repository. Because the project skeleton changes frequently, it is convenient to externalize it to the Git repository for version management. The project skeleton template is a project skeleton code template under a specified development mode. The technical person in charge writes the project skeleton template according to the project type and uploads it to the cloud service platform, where the project types include front-end, back-end, big data and applets. For each project type, a corresponding project skeleton code template is stored in the cloud service platform.

[0062] The project creation instruction sent by the client tool includes a project name and a project type identification code, and the project type identification code is set according to the project type. Specifically, the project identification code of the front end is front, the project identification code of the back end is service, the project identification code of the big data is data, and the project identification code of the mini program is micro.

[0063] S102. The cloud service platform matches the project skeleton template according to the project creation instruction, and renders the matched project skeleton template to obtain a project skeleton code.

[0064] Specifically, the cloud service platform matches the project skeleton template according to the project type identification code of the project creation instruction. After matching the project skeleton template, the cloud service platform reads the address, account and password for accessing the Git code repository from the Nacos configuration parameters, pulls and stores it in the initially prepared directory / tmp / random directory naming through the Git clone command, and the template engine reads it in file stream mode through the path specified in the target rendering file list.

[0065] S103: Determine whether the project skeleton template is rendered successfully.

[0066] After the project skeleton template is rendered, the template engine is used to determine whether the rendering is successful. The template engine defines the template file according to the engine specification. Before the template needs to be parsed and rendered, the variables required by the template are combined according to the actual scene and passed to the template engine at the same time as the template file. The template engine replaces the variables in the template with the implemented content and returns it to the calling logic. If there is an error in the parsing and rendering process, the engine will throw an exception message, which will be captured by the calling logic and regarded as a parsing and rendering failure. Specifically, the template engine in the present invention is a Velocity template engine, which is a Java-based template engine that allows anyone to simply use the template language to reference objects defined by Java code.

[0067] S104. If the project skeleton template is rendered successfully, the first status code and the project skeleton code are compressed and packaged into a first compressed package, and returned to the client tool.

[0068] S105. The client tool receives the first compressed package returned by the cloud service platform, and analyzes the first status code.

[0069] S106: Determine whether the first status code responds to success.

[0070] The status code is a code assigned by the cloud service platform when receiving each client tool request, and different status codes represent different response statuses. The first status code is a status code generated by the cloud service platform after receiving the project creation instruction sent by the client tool, 200 represents a successful response, and non-200 represents a failed response.

[0071] S107. If the first status code response is success, decompress the first compressed package into a local working directory.

[0072] The functional module code generation method comprises the following steps:

[0073] S201. Create a function module template and a data table on the cloud service platform.

[0074] The function module is either a traditional function or algorithm definition, or a business module or specific function in a system, and is a group module unit divided according to the specific definition after business analysis. In one embodiment, the function module template is a function module code template corresponding to a group module unit divided according to the specific definition after specific business demand analysis, and is maintained by a dedicated person and submitted to the template directory vm in the cloud service platform code. Because the function module code template changes less, it is directly built into the template directory of the cloud service platform project, and the data table can insert, delete, query and modify data.

[0075] S202. The client tool sends a function module code generation instruction to the cloud service platform.

[0076] S203. The cloud service platform generates instructions according to the functional module code and searches the data table.

[0077] S204: Determine whether there is a data table corresponding to the function module code generation instruction.

[0078] S205. If there is a corresponding data table, the corresponding data table is rendered according to the function module template to generate a function module code.

[0079] The function module code generation instruction includes a project name and a data table name, and the cloud service platform searches for a data table in a database resource according to the data table name. When a data table corresponding to the data table name is found, the corresponding data table is rendered according to the function module template to generate the function module code. Specifically, the template engine reads the function module template code stored in the template directory (vm) in the cloud service platform code in a file stream manner through the path specified in the target rendering file list. Among them, the project name is the same as the project name in the project creation instruction, and the function module code includes control class, logic class, data class and data operation code.

[0080] S206: Determine whether the functional module template is rendered successfully.

[0081] After the functional module template is rendered, a template engine is used to determine whether the rendering is successful. The template engine is the same as the template engine used to determine whether the project skeleton template is successfully rendered.

[0082] S207. If the function module template is rendered successfully, the second status code and the function module code are compressed and packaged into a second compressed package, and returned to the client tool.

[0083] S208. The client tool receives the second compressed package returned by the cloud service platform and analyzes the second status code;

[0084] S209. Determine whether the second status code responds to success;

[0085] S210. If the second status code response is success, decompress the second compressed package to the project source code directory under the local directory.

[0086] The second status code is a status code generated by the cloud service platform after receiving the function module code generation instruction sent by the client tool. 200 indicates a successful response, and non-200 indicates a failed response.

[0087] The cloud service platform receives the project creation instruction, and when the project type identification code indicates backend or big data, converts the project name into lowercase characters and uses it as the database name and the account name for logging into the database, randomly generates an irregular password of no less than 8 digits, and creates the database.

[0088] The database name, account name and password are encrypted and saved in the resource allocation table, and the cloud service platform allocates resources for the resource allocation table. The Nacos interface in the resource allocation table is requested to create the service configuration, and the account and password of the database are written into the development and test namespace. Among them, the development and test namespace is named by the cloud service platform in accordance with the development and testing and combined with the Nacos interface. The account and password of the database are written into the development and test namespace, and developers can access the database data without using the database account and password, which also facilitates the replacement and maintenance of the database account and password.

[0089] By applying the embodiments of the present invention, through the pre-writing of the project skeleton template and the function module template and the pre-creation of the data table, after the developer sends the project creation instruction and the function module code generation instruction through the client tool, the cloud service platform renders the project skeleton template according to the project creation instruction and the function module code generation instruction and renders the data table based on the function module template to obtain the code, and automatically decompresses and copies the code to the working directory, thereby unifying the development specifications and improving the development timeliness.

[0090] Corresponding to the above method embodiment, the embodiment of the present invention provides a software engineering code generation device, including a project skeleton code generation device 300 and a function module code generation device 400;

[0091] The project skeleton code generating device comprises:

[0092] A project instruction creation unit 301, in which the client tool sends a project creation instruction to a cloud service platform, wherein the cloud service platform stores a pre-written project skeleton template;

[0093] The project skeleton code generating unit 302, the cloud service platform matches the project skeleton template according to the project creation instruction, and renders the matched project skeleton template to obtain the project skeleton code;

[0094] The first judging unit 303 judges whether the project skeleton template is rendered successfully;

[0095] The project skeleton code downloading unit 304 compresses and packages the first status code and the project skeleton code into a first compressed package and returns it to the client tool if the project skeleton template is rendered successfully;

[0096] A first status code analysis unit 305, wherein the client tool receives the first compressed package returned by the cloud service platform and analyzes the first status code;

[0097] A second judging unit 306, judging whether the first status code response is successful;

[0098] A first decompression unit 307 decompresses the first compressed package into a local working directory if the first status code response is success;

[0099] The functional module code generating device 400 comprises:

[0100] A template and data table creation unit 401 creates a function module template and a data table on the cloud service platform;

[0101] Instruction sending unit 402, the client tool sends a function module code generation instruction to the cloud service platform;

[0102] A data table search unit 403, wherein the cloud service platform searches the data table according to the function module code generation instruction;

[0103] The third judgment unit 404 judges whether there is a data table corresponding to the function module code generation instruction;

[0104] The function module code generating unit 405 generates the function module code by rendering the corresponding data table according to the function module template if there is a corresponding data table;

[0105] The fourth judging unit 406 judges whether the functional module template is rendered successfully;

[0106] The function module code downloading unit 407 compresses and packages the second status code and the function module code into a second compressed package and returns it to the client tool if the function module template is rendered successfully;

[0107] A second status code analysis unit 408, wherein the client tool receives the second compressed package returned by the cloud service platform and analyzes the second status code;

[0108] A fifth determination unit 409 determines whether the second status code response is successful;

[0109] The second decompression unit 410 decompresses the second compressed package into the project source code directory under the local directory if the second status code response is success.

[0110] By applying the embodiments of the present invention, through the pre-writing of the project skeleton template and the function module template and the pre-creation of the data table, after the developer sends the project creation instruction and the function module code generation instruction through the client tool, the cloud service platform renders the project skeleton template according to the project creation instruction and the function module code generation instruction and renders the data table based on the function module template to obtain the code, and automatically decompresses and copies the code to the working directory, thereby unifying the development specifications and improving the development timeliness.

[0111] The above-mentioned embodiments only express several implementation methods of the present invention, and the description is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, and the present invention is also intended to include these modifications and modifications.

Claims

1. A software engineering code generation method, It is characterized in that Including project skeleton code generation method and function module code generation method; The project skeleton code generation method comprises: The client tool sends a project creation instruction to the cloud service platform, wherein the cloud service platform stores a pre-written project skeleton template; The cloud service platform matches the project skeleton template according to the project creation instruction, and renders the matched project skeleton template to obtain the project skeleton code; Determine whether the project skeleton template is rendered successfully; If the project skeleton template is rendered successfully, the first status code and the project skeleton code are compressed and packaged into a first compressed package, and returned to the client tool; The client tool receives the first compressed package returned by the cloud service platform, and analyzes the first status code; Determine whether the first status code response is successful; If the first status code response is success, decompress the first compressed package into a local working directory; The function module code generation method comprises: Creating a function module template and a data table on the cloud service platform; The client tool sends a function module code generation instruction to the cloud service platform; The cloud service platform searches the data table according to the function module code generation instruction; Determine whether there is a data table corresponding to the function module code generation instruction; If there is a corresponding data table, the corresponding data table is rendered according to the function module template to generate the function module code; Determine whether the functional module template is rendered successfully; If the function module template is rendered successfully, compress and package the second status code and the function module code into a second compressed package, and return it to the client tool; The client tool receives the second compressed package returned by the cloud service platform, and analyzes the second status code; Determine whether the second status code responds to success; If the second status code response is success, the second compressed package is decompressed to the project source code directory under the local working directory.

2. A method for generating software engineering code according to claim 1, Features: The project creation instruction includes a project name and a project type identification code, and the cloud service platform matches the project skeleton template according to the project type identification code.

3. A method for generating software engineering code according to claim 1, Features: The function module code generation instruction includes a project name and a data table name, and the cloud service platform searches for the data table according to the data table name.

4. A method for generating software engineering code according to claim 2, Features: The cloud service platform receives the project creation instruction, and when the project type identification code indicates backend or big data, converts the project name into lowercase characters and uses it as the database name and the account name for logging into the database, randomly generates an irregular password of no less than 8 digits, and creates the database.

5. A method for generating software engineering code according to claim 4, Features: The database name, account name and password are encrypted and saved in a resource allocation table, and the cloud service platform performs resource allocation on the resource allocation table.

6. A method for generating software engineering code according to claim 5, Features: Request the Nacos interface in the resource allocation table to create a service configuration, and write the account and password of the database into the development and test namespaces.

7. A method for generating software engineering code according to claim 1, Features: The project skeleton template includes front-end, back-end, big data and mini-program skeleton templates.

8. A method for generating software engineering code according to claim 1, Features: The functional module codes include control class, logic class, data class and data operation code.

9. A software engineering code generation device, It is characterized in that It includes a project skeleton code generating device and a function module code generating device; The project skeleton code generating device comprises: A project instruction creation unit, wherein the client tool sends a project creation instruction to a cloud service platform, wherein the cloud service platform stores a pre-written project skeleton template; A project skeleton code generating unit, wherein the cloud service platform matches the project skeleton template according to the project creation instruction, and renders the matched project skeleton template to obtain a project skeleton code; A first judging unit, judging whether the project skeleton template is rendered successfully; The project skeleton code downloading unit compresses and packages the first status code and the project skeleton code into a first compressed package if the project skeleton template is rendered successfully, and returns the first compressed package to the client tool; A first status code analysis unit, wherein the client tool receives the first compressed package returned by the cloud service platform and analyzes the first status code; A second judgment unit, judging whether the first status code response is successful; A first decompression unit, if the first status code response is success, decompressing the first compressed package into a local working directory; The functional module code generating device comprises: A template and data table creation unit, which creates function module templates and data tables on the cloud service platform; An instruction sending unit, wherein the client tool sends a function module code generation instruction to the cloud service platform; A data table search unit, wherein the cloud service platform searches the data table according to the function module code generation instruction; A third judgment unit is used to judge whether there is a data table corresponding to the function module code generation instruction; The function module code generating unit renders the corresponding data table according to the function module template to generate the function module code if there is a corresponding data table; A fourth judgment unit, judging whether the functional module template is rendered successfully; The function module code downloading unit compresses and packages the second status code and the function module code into a second compressed package if the function module template is rendered successfully, and returns the second compressed package to the client tool; A second status code analysis unit, wherein the client tool receives the second compressed package returned by the cloud service platform and analyzes the second status code; A fifth judging unit, judging whether the second status code is responded as successful; The second decompression unit decompresses the second compressed package to the project source code directory under the local working directory if the second status code response is successful.

Citation Information

Patent Citations

  • A project creation system and an automated project creation method

    CN109582302A

  • Automatic code generation method based on java language

    CN110825369A