WO2019024543A1 - Code generation method and apparatus, code generator and readable storage medium - Google Patents

Code generation method and apparatus, code generator and readable storage medium Download PDF

Info

Publication number
WO2019024543A1
WO2019024543A1 PCT/CN2018/083942 CN2018083942W WO2019024543A1 WO 2019024543 A1 WO2019024543 A1 WO 2019024543A1 CN 2018083942 W CN2018083942 W CN 2018083942W WO 2019024543 A1 WO2019024543 A1 WO 2019024543A1
Authority
WO
WIPO (PCT)
Prior art keywords
code
template
user
preset value
repetitions
Prior art date
Application number
PCT/CN2018/083942
Other languages
French (fr)
Chinese (zh)
Inventor
徐广�
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019024543A1 publication Critical patent/WO2019024543A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse

Definitions

  • the present application relates to the field of code generation, and in particular, to a code generation method, apparatus, code generator, and computer readable storage medium.
  • programmers have a lot of repetitive program code to write during the process of developing a software project.
  • it is generally written by a programmer, or generated by an existing code generator.
  • the main purpose of the present application is to provide a code generation method, a code generation device, a code generator, and a computer readable storage medium, which are intended to solve the technical problem of long development cycle, complicated operation of generating code, and inflexible operation.
  • the present application provides a code generating method, where the method includes:
  • the code in the crawl code development system that repeats the number of times greater than or equal to the preset value, and the code whose repetition number is greater than or equal to the preset value is entered into the system, and the step of forming the code template further includes :
  • Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
  • the method further includes:
  • the number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
  • the code in the crawl code development system that repeats the number of times greater than or equal to the preset value, and the code whose repetition number is greater than or equal to the preset value is entered into the system, and the step of forming the code template further includes :
  • the user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
  • the step of copying the code whose number of repetitions is less than a preset value into the generated code template includes:
  • the present application further provides a code generating apparatus, where the apparatus includes:
  • a capture module configured to capture a code whose number of repetitions is greater than or equal to a preset value in the code development system, and enter the code whose repetition number is greater than or equal to a preset value into the template system to form a code template;
  • a receiving module configured to receive a code template path input by the user, extract a corresponding code template according to the code template path, and receive a code that the number of repetitions in the development system input by the user is less than a preset value
  • a copy module configured to copy the code whose number of repetitions is less than a preset value into the code generated in the extracted code template.
  • the present application further provides a code generator, the code generator comprising a processor and a memory, wherein the memory stores a code generation program; the processor is configured to execute the code generation program, To achieve the following steps:
  • the processor is further configured to execute the code generating program to implement the following steps:
  • Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
  • the processor is further configured to execute the code generating program to implement the following steps:
  • the number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
  • the processor is further configured to execute the code generating program to implement the following steps:
  • the user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
  • the processor is further configured to execute the code generating program to implement the following steps:
  • the code generation method, the code generation method, the code generator and the computer readable storage medium provided by the application by capturing code in the code development system whose repetition times are greater than or equal to a preset value, and the number of repetitions is greater than or equal to
  • the set value code is entered into the template system to form a code template to form a code template; then, the code template path input by the user is received, and the corresponding code template is extracted according to the code template path, and the number of repetitions in the development system receiving the user input is less than The code of the preset value; the code that repeats the number of repetitions less than the preset value is copied into the extracted code template to generate the code, and the user can generate the code without performing complicated operation steps, thereby saving the programmer's human input.
  • Improve code generation efficiency and shorten software project development cycle by capturing code in the code development system whose repetition times are greater than or equal to a preset value, and the number of repetitions is greater than or equal to
  • the set value code is entered into the template system to
  • FIG. 1 is a schematic flow chart of a first embodiment of a code generating method according to the present application.
  • FIG. 2 is a schematic flowchart of a second embodiment of a code generating method according to the present application.
  • FIG. 3 is a schematic flowchart of a third embodiment of a code generating method according to the present application.
  • FIG. 4 is a schematic flowchart of a fourth embodiment of a code generating method according to the present application.
  • FIG. 5 is a schematic flowchart of the steps of copying the basic information of the generated required code to the generated code in the extracted code template in the fifth embodiment of the code generating method of the present application;
  • FIG. 6 is a schematic structural diagram of a device in a hardware operating environment according to an embodiment of the present application.
  • the main solution of the embodiment of the present application is: by crawling the code development system, the code whose repetition number is greater than or equal to the preset value, and the code whose repetition number is greater than or equal to the preset value is entered into the template system to form a code. Forming a code template; then receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code in the development system input by the user that is less than a preset value; and the repetition number is less than The code of the preset value is copied into the extracted code template to generate the code, and the user can generate the code without performing complicated operation steps, thereby saving the programmer's manpower investment, improving the code generation efficiency, and shortening the software project development cycle.
  • the embodiment of the present application considers that in the prior art, it is generally written by a programmer, or generated by an existing code generator. Repeated writing by the programmer will lead to a longer software project development cycle, which will increase the programmer's programming burden, and the code generation through the existing code generator can only generate simple code and need to generate relatively complex code. The operation of generating code is complicated, and the operation is not flexible, which is not conducive to user operation.
  • the embodiment of the present application provides a code generation method, by capturing a code whose number of repetitions is greater than or equal to a preset value in a code development system, and inputting the code whose repetition number is greater than or equal to a preset value into a template system.
  • Forming a code template to form a code template then receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code whose number of repetitions in the development system input by the user is less than a preset value;
  • the code that repeats the number of times less than the preset value is copied into the extracted code template to generate the code, and the user can generate the code without performing complicated operation steps, thereby saving the programmer's manpower investment, improving the code generation efficiency, and shortening the software. Project development cycle.
  • FIG. 1 is a schematic flowchart of a first embodiment of a code generating method according to the present application.
  • the method includes:
  • Step S10 capturing a code whose number of repetitions is greater than or equal to a preset value in the code development system, and inputting the code whose repetition number is greater than or equal to the preset value into the template system to form a code template;
  • the number of occurrences of each code may be counted in the software project development system, and then the code in the code development system whose repetition number is greater than or equal to the preset value may be captured, and the repetition number is greater than or equal to
  • the preset value code is entered into the template system to form a code template; specifically, the generated code template can be a template for converting a string into a certain format, or a code template having a connection database function;
  • the preset value can be determined according to the total number of program codes developed by each software project. When the total number of program codes developed by the software project is large, more programs need to be written, and the preset value can be set to a smaller value at this time.
  • the process of extracting the code and forming the code template can be completed by the local development device, or can be completed on the external device, and then imported into the local development device.
  • Step S20 receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code that the number of repetitions in the development system input by the user is less than a preset value;
  • the user can directly input the code template path, and the system can extract the corresponding code template according to the code template path.
  • the user can perform the function according to the functions required by the developed software project.
  • the code that is not in the code template can be input into the system, and will be developed in the system.
  • a code input system that repeats less than the preset value. Therefore, after the code template is extracted, it is also required to receive a code in which the number of repetitions in the development system input by the user is less than a preset value.
  • the code template before extracting the code template, the code template can also be extracted by inputting the function to be realized by the developed project.
  • Step S30 copying the code whose number of repetitions is less than a preset value to the code generated in the extracted code template.
  • copying the code in the development system that is less than the preset value to the extracted code template may generate the code.
  • the code generating method in this embodiment captures a code whose number of repetitions is greater than or equal to a preset value in a code development system, and records the code whose repetition number is greater than or equal to a preset value into a template system to form a code template.
  • Forming a code template then receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code whose number of repetitions in the development system input by the user is less than a preset value;
  • the code of the value is copied into the extracted code template to generate the code, and the user can generate the code without performing complicated operation steps, thereby saving the programmer's manpower investment, improving the code generation efficiency, and shortening the software project development cycle.
  • a second embodiment of the code generating method of the present application is proposed based on the first embodiment of the code generating method of the present application.
  • step after the step S10 further includes:
  • Step S40 Receive a code specification input by a user in a formed code template, where the code specification includes a code vulnerability and a system vulnerability;
  • Step S50 automatically generating code to avoid the code vulnerability and system vulnerability according to the code specification.
  • the user may further input a code specification into the generated code template, where the code specification includes a code vulnerability and a system vulnerability, and the code vulnerability is a common code vulnerability that has been discovered,
  • the latest discovered code vulnerabilities, etc., code vulnerabilities can be manifested in many aspects, the algorithm itself or the code itself may cause code loopholes.
  • the specific manifestations of code vulnerabilities mainly include: (1) The validity of the input data is not checked or checked poorly, or the improper handling of buffer vulnerabilities is caused by this problem. For example, when entering a password, the user may enter a long password. If the program is not restricted, it may cause other problems to be overwritten when the password is stored. (2) Code logic design defects or errors are caused by programmers' care or inconsistency.
  • the algorithm's own vulnerability algorithm is the premise of security.
  • the loophole of the algorithm itself may lead to various problems. For example, using a simpler encryption algorithm may easily lead to information leakage, so it is necessary to prevent code vulnerabilities.
  • a common code template for avoiding code vulnerabilities and system vulnerabilities may be extracted in the system, and then the developer needs to perform functions according to the current development project.
  • Write personalized code to avoid code vulnerabilities and system vulnerabilities, and then upload them to the system.
  • the system receives the personalized code to avoid code vulnerabilities and system vulnerabilities uploaded by users, and copies them to corresponding code vulnerabilities and system vulnerabilities.
  • the code for avoiding the code vulnerabilities and system vulnerabilities for the current development project can be automatically generated, thereby preventing potential harm to the program itself, the system or the data due to the inconsistency of the programming itself.
  • the code generation method of the embodiment by receiving a code specification input by a user in a generated code template, wherein the code specification includes a code vulnerability and a system vulnerability; and then automatically generating a code vulnerability and system according to the code specification Vulnerability code to prevent potential harm to the program itself, system or data due to poorly designed programming itself.
  • a third embodiment of the code generating method of the present application is proposed based on the first embodiment of the code generating method of the present application.
  • step after the step S30 further includes:
  • Step S60 performing automatic testing on the generated code, and generating a test report
  • Step S70 adjusting the code template according to the test report, and updating the adjusted code template
  • Step S80 Perform statistics on the number of times the code template is used according to a preset period, generate a usage report, and use the usage report as a reference for generating the code template.
  • the generated code may be further tested automatically, whether the test code has a problem, and then a test report is generated, so that the user knows whether the generated code has a problem, and if the generated code has a problem, There is a problem with the code for the user, so that the user can change it.
  • the code template can be further adjusted according to the test report, and the adjusted code template is updated to make the code template more precise. Further, the number of times of using each code template may be counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
  • the code generation method proposed in this embodiment automatically tests the generated code and generates a test report, so that the user knows whether the generated code has a problem and the specific location where the problem occurs; and then performs the code template according to the test report. Adjust, and update the adjusted code template to make the code template more accurate; finally, the number of times the code template is used can be counted according to a preset period, and a usage report is generated to generate the usage report as a code template. reference.
  • a fourth embodiment of the code generating method of the present application is proposed based on the first embodiment of the code generating method of the present application.
  • step after the step S10 further includes:
  • Step S90 receiving a keyword input by the user, and pushing the code template to the user according to the keyword;
  • Step S100 monitoring the order in which the user uses the pushed code template, analyzing the relationship between the code templates according to the order in which the user uses the code template, and pushing the associated code template to the user.
  • the user in addition to obtaining the code template by directly inputting the code template path, the user can also obtain the code template by inputting the function to be implemented by the developed software project. Therefore, after receiving the keyword input by the user, the received keyword can be matched with the retained code template, and the matched code template is pushed to the user. At the same time, in the process of using the pushed code template, the user can further monitor the order of the user using the pushed code template, and then analyze the relationship between the code templates according to the order of the user using the code template, and push the associated code template to the user to improve The experience of users using code templates.
  • the code generating method provided in this embodiment can push the code template to the user according to the keyword by receiving the keyword input by the user; and then monitor the order of the user using the pushed code template, according to the order of the user using the code template. Analyze the relationship between each code template, push the associated code template to the user, and improve the user experience of using the code template.
  • a fifth embodiment of the code generating method of the present application is proposed based on any one of the first to fourth embodiments of the code generating method of the present application.
  • step S30 includes:
  • Step S31 acquiring a corresponding location of the basic information of the generated required code in the code template
  • Step S32 copying the basic information for generating the required code to the corresponding location generation code in the code template.
  • the embodiment of the present application further provides a code generating apparatus, where the apparatus includes:
  • a capture module configured to capture a code whose number of repetitions is greater than or equal to a preset value in the code development system, and enter the code whose repetition number is greater than or equal to a preset value into the template system to form a code template;
  • a receiving module configured to receive a code template path input by the user, extract a corresponding code template according to the code template path, and receive a code that the number of repetitions in the development system input by the user is less than a preset value
  • a copy module configured to copy the code whose number of repetitions is less than a preset value into the code generated in the extracted code template.
  • the embodiment of the present application further provides a code generator.
  • the code generator can include a processor 1001, such as a CPU, a network interface 1002, a user interface 1003, and a memory 1004. Connection communication between these components can be achieved via a communication bus.
  • the network interface 1002 may optionally include a standard wired interface (for connecting to a wired network), a wireless interface (such as a WI-FI interface, a Bluetooth interface, an infrared interface, etc. for connecting to a wireless network).
  • the user interface 1003 can include a display, an input unit such as a keyboard, and the optional user interface 1003 can also include a standard wired interface (eg, for connecting a wired keyboard, a wired mouse, etc.) and/or a wireless interface (eg, Used to connect a wireless keyboard, wireless mouse).
  • the memory 1004 may be a high speed RAM memory or a stable memory (non-volatile) Memory), such as disk storage.
  • the memory 1004 can also optionally be a storage device independent of the aforementioned processor 1001.
  • code generator structure shown in FIG. 6 does not constitute a limitation to the code generator, and may include more or less components than those illustrated, or combine some components or different components. Arrangement.
  • an operating system and a code generator program may be included in the memory 1002 as a computer storage medium.
  • the operating system is a program that manages the hardware and software resources of the code generator, and supports the running of the code generator program and other software or programs.
  • the processor 1001 can be used to execute a code generation program stored in the memory 1002 to implement the following steps:
  • processor 1001 can also execute a code generation program stored in the memory 1002 to implement the following steps:
  • Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
  • processor 1001 can also execute a code generation program stored in the memory 1002 to implement the following steps:
  • the number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
  • processor 1001 can also execute a code generation program stored in the memory 1002 to implement the following steps:
  • the user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
  • processor 1001 can also execute a code generation program stored in the memory 1002 to implement the following steps:
  • the application provides a computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the following steps:
  • the one or more programs may be executed by the one or more processors, and the following steps are also implemented:
  • Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
  • the one or more programs may be executed by the one or more processors, and the following steps are also implemented:
  • the number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
  • the one or more programs may be executed by the one or more processors, and the following steps are also implemented:
  • the user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
  • the one or more programs may be executed by the one or more processors, and the following steps are also implemented:
  • the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better.
  • Implementation Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
  • the optical disc includes a number of instructions for causing a terminal device (which may be a cell phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods of various embodiments of the present application.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

Disclosed is a code generation method, the method comprising: capturing a code, the amount of repetition of same being greater than or equal to a pre-set value, in a code development system, and entering the code, the amount of repetition of same being greater than or equal to the pre-set value, into a template system to form a code template; receiving a code template path input by a user, extracting a corresponding code template according to the code template path, and receiving a code input by the user, the amount of repetition of same being less than the pre-set value, in the development system; and copying the code, the amount of repetition of same being less than the pre-set value, to the extracted code template to generate a code. Also disclosed are a code generation apparatus, a code generator and computer-readable storage medium. This application can save on the investment in code writing labour and improve the efficiency of code generation.

Description

代码生成方法、装置、代码生成器及可读存储介质  Code generation method, device, code generator and readable storage medium
本申请要求于2017年8月1日提交中国专利局、申请号为201710656395.4、发明名称为“代码生成方法、代码生成器及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。The present application claims priority to Chinese Patent Application No. 200910656395.4, entitled "Code Generation Method, Code Generator, and Computer Readable Storage Media", filed on August 1, 2017, the entire contents of which are incorporated by reference. The citation is incorporated in the application.
技术领域Technical field
本申请涉及代码生成领域,尤其涉及一种代码生成方法、装置、代码生成器及计算机可读存储介质。The present application relates to the field of code generation, and in particular, to a code generation method, apparatus, code generator, and computer readable storage medium.
背景技术Background technique
目前,程序员在开发软件项目过程中,有很多重复的程序代码需要编写,现有技术中,一般是通过程序员进行重复编写编写,或者通过现有的代码生成器进行生成代码。At present, programmers have a lot of repetitive program code to write during the process of developing a software project. In the prior art, it is generally written by a programmer, or generated by an existing code generator.
通过程序员进行重复编写编写,会导致软件项目开发周期较长,加重程序员的编程负担,而通过现有的代码生成器进行代码生成,只能生成简单的代码,需要生成相对复杂的代码时,生成代码的操作比较复杂,操作不灵活,不利于用户操作。Repeated writing by the programmer will lead to a longer software project development cycle, which will increase the programmer's programming burden, and the code generation through the existing code generator can only generate simple code and need to generate relatively complex code. The operation of generating code is complicated, and the operation is not flexible, which is not conducive to user operation.
申请内容Application content
本申请的主要目的在于提出一种代码生成方法、代码生成装置、代码生成器及计算机可读存储介质,旨在解决开发周期较长,生成代码的操作比较复杂,操作不灵活的技术问题。The main purpose of the present application is to provide a code generation method, a code generation device, a code generator, and a computer readable storage medium, which are intended to solve the technical problem of long development cycle, complicated operation of generating code, and inflexible operation.
为实现上述目的,本申请提供一种代码生成方法,所述方法包括:To achieve the above objective, the present application provides a code generating method, where the method includes:
抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;Grab the code in the code development system that the number of repetitions is greater than or equal to the preset value, and enter the code whose repetition number is greater than or equal to the preset value into the template system to form a code template;
接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;Receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code that the number of repetitions in the development system input by the user is less than a preset value;
将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。Copying the code whose number of repetitions is less than the preset value to the code generated in the extracted code template.
可选地,所述抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到系统中,形成代码模板的步骤之后还包括: Optionally, the code in the crawl code development system that repeats the number of times greater than or equal to the preset value, and the code whose repetition number is greater than or equal to the preset value is entered into the system, and the step of forming the code template further includes :
接收用户在形成的代码模板中输入的代码规范,其中,所述代码规范包括代码漏洞及系统漏洞;Receiving a code specification entered by a user in a formed code template, wherein the code specification includes a code vulnerability and a system vulnerability;
根据所述代码规范自动生成避免所述代码漏洞及系统漏洞的代码。Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
可选地,将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码的步骤之后还包括:Optionally, after the step of copying the code whose number of repetitions is less than the preset value to the generated code in the extracted code template, the method further includes:
对生成的代码进行自动测试,并生成测试报告;Automatically test the generated code and generate a test report;
根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新;Adjusting the code template according to the test report, and updating the adjusted code template;
根据预设的周期对代码模板的使用次数进行统计,生成使用报告,并将所述使用报告作为代码模板生成的参考。 The number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
可选地,所述抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到系统中,形成代码模板的步骤之后还包括:Optionally, the code in the crawl code development system that repeats the number of times greater than or equal to the preset value, and the code whose repetition number is greater than or equal to the preset value is entered into the system, and the step of forming the code template further includes :
接收用户输入的关键词,根据所述关键词向用户推送代码模板;Receiving a keyword input by the user, and pushing the code template to the user according to the keyword;
监测用户使用推送的代码模板的先后顺序,根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板。The user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
可选地,所述将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码的步骤包括:Optionally, the step of copying the code whose number of repetitions is less than a preset value into the generated code template includes:
获取所述重复次数小于预设值的代码在代码模板中的对应位置;Obtaining a corresponding position of the code whose number of repetitions is less than a preset value in the code template;
将所述重复次数小于预设值的代码复制至代码模板中的对应位置生成代码。Copying the code whose number of repetitions is less than the preset value to the corresponding location generation code in the code template.
此外,为实现上述目的,本申请还提供一种代码生成装置,所述装置包括:In addition, to achieve the above object, the present application further provides a code generating apparatus, where the apparatus includes:
抓取模块,用于抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;a capture module, configured to capture a code whose number of repetitions is greater than or equal to a preset value in the code development system, and enter the code whose repetition number is greater than or equal to a preset value into the template system to form a code template;
接收模块,用于接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;a receiving module, configured to receive a code template path input by the user, extract a corresponding code template according to the code template path, and receive a code that the number of repetitions in the development system input by the user is less than a preset value;
复制模块,用于将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。And a copy module, configured to copy the code whose number of repetitions is less than a preset value into the code generated in the extracted code template.
此外,为实现上述目的,本申请还提供一种代码生成器,所述代码生成器包括处理器及存储器,所述存储器中存储有代码生成程序;所述处理器用于执行所述代码生成程序,以实现以下步骤:In addition, in order to achieve the above object, the present application further provides a code generator, the code generator comprising a processor and a memory, wherein the memory stores a code generation program; the processor is configured to execute the code generation program, To achieve the following steps:
抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;Grab the code in the code development system that the number of repetitions is greater than or equal to the preset value, and enter the code whose repetition number is greater than or equal to the preset value into the template system to form a code template;
接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;Receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code that the number of repetitions in the development system input by the user is less than a preset value;
将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。Copying the code whose number of repetitions is less than the preset value to the code generated in the extracted code template.
可选地,所述处理器还用于执行所述代码生成程序,以实现以下步骤:Optionally, the processor is further configured to execute the code generating program to implement the following steps:
接收用户在形成的代码模板中输入的代码规范,其中,所述代码规范包括代码漏洞及系统漏洞;Receiving a code specification entered by a user in a formed code template, wherein the code specification includes a code vulnerability and a system vulnerability;
根据所述代码规范自动生成避免所述代码漏洞及系统漏洞的代码。Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
可选地,所述处理器还用于执行所述代码生成程序,以实现以下步骤:Optionally, the processor is further configured to execute the code generating program to implement the following steps:
对生成的代码进行自动测试,并生成测试报告;Automatically test the generated code and generate a test report;
根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新;Adjusting the code template according to the test report, and updating the adjusted code template;
根据预设的周期对代码模板的使用次数进行统计,生成使用报告,并将所述使用报告作为代码模板生成的参考。 The number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
可选地,所述处理器还用于执行所述代码生成程序,以实现以下步骤:Optionally, the processor is further configured to execute the code generating program to implement the following steps:
接收用户输入的关键词,根据所述关键词向用户推送代码模板;Receiving a keyword input by the user, and pushing the code template to the user according to the keyword;
监测用户使用推送的代码模板的先后顺序,根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板。The user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
可选地,所述处理器还用于执行所述代码生成程序,以实现以下步骤:Optionally, the processor is further configured to execute the code generating program to implement the following steps:
获取所述重复次数小于预设值的代码在代码模板中的对应位置;Obtaining a corresponding position of the code whose number of repetitions is less than a preset value in the code template;
将所述重复次数小于预设值的代码复制至代码模板中的对应位置生成代码。Copying the code whose number of repetitions is less than the preset value to the corresponding location generation code in the code template.
本申请提出的代码生成方法、代码生成方法、代码生成器及计算机可读存储介质,通过抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板,形成代码模板;然后接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;将所述重复次数小于预设值的代码复制至提取到的代码模板中即可生成代码,用户不需要进行复杂的操作步骤即可生成代码,从而节省程序员的人力投入,提高代码生成效率,缩短软件项目开发周期。The code generation method, the code generation method, the code generator and the computer readable storage medium provided by the application, by capturing code in the code development system whose repetition times are greater than or equal to a preset value, and the number of repetitions is greater than or equal to The set value code is entered into the template system to form a code template to form a code template; then, the code template path input by the user is received, and the corresponding code template is extracted according to the code template path, and the number of repetitions in the development system receiving the user input is less than The code of the preset value; the code that repeats the number of repetitions less than the preset value is copied into the extracted code template to generate the code, and the user can generate the code without performing complicated operation steps, thereby saving the programmer's human input. Improve code generation efficiency and shorten software project development cycle.
附图说明DRAWINGS
图1为本申请代码生成方法第一实施例的流程示意图;1 is a schematic flow chart of a first embodiment of a code generating method according to the present application;
图2为本申请代码生成方法第二实施例的流程示意图;2 is a schematic flowchart of a second embodiment of a code generating method according to the present application;
图3为本申请代码生成方法第三实施例的流程示意图;3 is a schematic flowchart of a third embodiment of a code generating method according to the present application;
图4为本申请代码生成方法第四实施例的流程示意图;4 is a schematic flowchart of a fourth embodiment of a code generating method according to the present application;
图5为本申请代码生成方法第五实施例中将所述生成所需代码的基本信息复制至提取到的代码模板中生成代码的步骤的细化流程示意图;FIG. 5 is a schematic flowchart of the steps of copying the basic information of the generated required code to the generated code in the extracted code template in the fifth embodiment of the code generating method of the present application;
图6是本申请实施例方案涉及的硬件运行环境的设备结构示意图。FIG. 6 is a schematic structural diagram of a device in a hardware operating environment according to an embodiment of the present application.
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings.
具体实施方式Detailed ways
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
本申请实施例的主要解决方案是:通过抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板,形成代码模板;然后接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;将所述重复次数小于预设值的代码复制至提取到的代码模板中即可生成代码,用户不需要进行复杂的操作步骤即可生成代码,从而节省程序员的人力投入,提高代码生成效率,缩短软件项目开发周期。The main solution of the embodiment of the present application is: by crawling the code development system, the code whose repetition number is greater than or equal to the preset value, and the code whose repetition number is greater than or equal to the preset value is entered into the template system to form a code. Forming a code template; then receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code in the development system input by the user that is less than a preset value; and the repetition number is less than The code of the preset value is copied into the extracted code template to generate the code, and the user can generate the code without performing complicated operation steps, thereby saving the programmer's manpower investment, improving the code generation efficiency, and shortening the software project development cycle.
本申请实施例考虑到,现有技术中,一般是通过程序员进行重复编写编写,或者通过现有的代码生成器进行生成代码。通过程序员进行重复编写编写,会导致软件项目开发周期较长,加重程序员的编程负担,而通过现有的代码生成器进行代码生成,只能生成简单的代码,需要生成相对复杂的代码时,生成代码的操作比较复杂,操作不灵活,不利于用户操作。The embodiment of the present application considers that in the prior art, it is generally written by a programmer, or generated by an existing code generator. Repeated writing by the programmer will lead to a longer software project development cycle, which will increase the programmer's programming burden, and the code generation through the existing code generator can only generate simple code and need to generate relatively complex code. The operation of generating code is complicated, and the operation is not flexible, which is not conducive to user operation.
为此,本申请实施例提出一种代码生成方法,通过抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板,形成代码模板;然后接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;将所述重复次数小于预设值的代码复制至提取到的代码模板中即可生成代码,用户不需要进行复杂的操作步骤即可生成代码,从而节省程序员的人力投入,提高代码生成效率,缩短软件项目开发周期。To this end, the embodiment of the present application provides a code generation method, by capturing a code whose number of repetitions is greater than or equal to a preset value in a code development system, and inputting the code whose repetition number is greater than or equal to a preset value into a template system. Forming a code template to form a code template; then receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code whose number of repetitions in the development system input by the user is less than a preset value; The code that repeats the number of times less than the preset value is copied into the extracted code template to generate the code, and the user can generate the code without performing complicated operation steps, thereby saving the programmer's manpower investment, improving the code generation efficiency, and shortening the software. Project development cycle.
参照图1,图1为本申请代码生成方法第一实施例的流程示意图。Referring to FIG. 1, FIG. 1 is a schematic flowchart of a first embodiment of a code generating method according to the present application.
在本实施例中,该方法包括:In this embodiment, the method includes:
步骤S10,抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;Step S10, capturing a code whose number of repetitions is greater than or equal to a preset value in the code development system, and inputting the code whose repetition number is greater than or equal to the preset value into the template system to form a code template;
在本实施例中,可以在软件项目开发系统中对各条代码出现的次数进行统计,然后抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;具体地,生成的代码模板可以为一个专门把字符串转换成一定格式的模板,或者为一个具有连接数据库功能的代码模板;其中,所述预设值可以根据各个软件项目开发的程序代码总条数决定,当软件项目开发的程序代码总条数较多时,需要编写的程序较多,此时预设值可以设置为较小的值,从而减少程序员的编写工作量,具体实施过程中,也可以根据用户的习惯进行设置。其中,提取代码以及形成代码模板的过程可以在本地开发设备完成,也可以在外部设备完成,然后导入本地开发设备中。In this embodiment, the number of occurrences of each code may be counted in the software project development system, and then the code in the code development system whose repetition number is greater than or equal to the preset value may be captured, and the repetition number is greater than or equal to The preset value code is entered into the template system to form a code template; specifically, the generated code template can be a template for converting a string into a certain format, or a code template having a connection database function; The preset value can be determined according to the total number of program codes developed by each software project. When the total number of program codes developed by the software project is large, more programs need to be written, and the preset value can be set to a smaller value at this time. Therefore, the programmer's writing workload is reduced, and the specific implementation process can also be set according to the user's habits. The process of extracting the code and forming the code template can be completed by the local development device, or can be completed on the external device, and then imported into the local development device.
步骤S20,接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;Step S20, receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code that the number of repetitions in the development system input by the user is less than a preset value;
在用户开发过程中,用户可以直接输入代码模板路径,系统即可根据所述代码模板路径提取对应的代码模板,在提取到代码模板之后,用户可以根据开发的软件项目需要实现的功能,对照提取到的代码模板,即可获知代码模板中已有的程序代码,再将开发的软件项目需要实现的功能对应需要编写的程序代码中,代码模板中没有的代码输入系统即可,即将开发系统中重复次数小于预设值的代码输入系统。因此,在提取到代码模板之后,还需要接收用户输入的开发系统中重复次数小于预设值的代码。具体实施过程中,在提取代码模板之前,也可以通过输入开发的项目所要实现的功能,进行提取代码模板。In the user development process, the user can directly input the code template path, and the system can extract the corresponding code template according to the code template path. After the code template is extracted, the user can perform the function according to the functions required by the developed software project. To the code template, you can know the existing program code in the code template, and then the function that needs to be realized by the developed software project corresponds to the program code that needs to be written. The code that is not in the code template can be input into the system, and will be developed in the system. A code input system that repeats less than the preset value. Therefore, after the code template is extracted, it is also required to receive a code in which the number of repetitions in the development system input by the user is less than a preset value. In the specific implementation process, before extracting the code template, the code template can also be extracted by inputting the function to be realized by the developed project.
步骤S30,将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。Step S30, copying the code whose number of repetitions is less than a preset value to the code generated in the extracted code template.
在提取到代码模板以及接收到用户输入的开发系统中重复次数小于预设值的代码之后,将所述开发系统中重复次数小于预设值的代码复制至提取到的代码模板中即可生成代码。After extracting the code template and the code that is less than the preset value in the development system that receives the user input, copying the code in the development system that is less than the preset value to the extracted code template may generate the code. .
本实施例提出的代码生成方法,通过抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板,形成代码模板;然后接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;将所述重复次数小于预设值的代码复制至提取到的代码模板中即可生成代码,用户不需要进行复杂的操作步骤即可生成代码,从而节省程序员的人力投入,提高代码生成效率,缩短软件项目开发周期。The code generating method in this embodiment captures a code whose number of repetitions is greater than or equal to a preset value in a code development system, and records the code whose repetition number is greater than or equal to a preset value into a template system to form a code template. Forming a code template; then receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code whose number of repetitions in the development system input by the user is less than a preset value; The code of the value is copied into the extracted code template to generate the code, and the user can generate the code without performing complicated operation steps, thereby saving the programmer's manpower investment, improving the code generation efficiency, and shortening the software project development cycle.
进一步地,参照图2,基于本申请代码生成方法第一实施例提出本申请代码生成方法第二实施例。Further, referring to FIG. 2, a second embodiment of the code generating method of the present application is proposed based on the first embodiment of the code generating method of the present application.
在本实施例中,所述步骤S10之后的步骤还包括:In this embodiment, the step after the step S10 further includes:
步骤S40,接收用户在形成的代码模板中输入的代码规范,其中,所述代码规范包括代码漏洞及系统漏洞;Step S40: Receive a code specification input by a user in a formed code template, where the code specification includes a code vulnerability and a system vulnerability;
步骤S50,根据所述代码规范自动生成避免所述代码漏洞及系统漏洞的代码。Step S50, automatically generating code to avoid the code vulnerability and system vulnerability according to the code specification.
在本实施例中,在形成代码模板之后,用户可以进一步对生成的代码模板中输入代码规范,其中,所述代码规范包括代码漏洞及系统漏洞,所述代码漏洞为已发现的常见代码漏洞、最新发现的代码漏洞等,代码漏洞可以表现在很多方面,算法本身或者代码本身的问题都可能会造成代码漏洞。代码漏洞的具体表现主要包括:(1)未对输入的数据进行有效性检查或者检查不周,或者处理不当通常所说的缓冲区漏洞都是由此问题引起。比如输入密码时,用户可能会输入超长的密码,如果程序未作限制可能就会导致存储密码时覆盖其它的数据从而引发问题。(2)代码逻辑设计缺陷或错误多由程序员大意或考虑不周造成。比如判断时少漏条件,当遇到特殊数据,可能导致程序出现意外的运行结果。(3)算法本身的漏洞严密的算法是安全的前提,算法本身的漏洞可能会导致多方面的问题,比如采用比较简单的加密算法可能会极易导致信息泄漏,因此需要对代码漏洞进行防范,具体地,在接收到用户在生成的代码模板中输入代码规范之后,可以在系统中提取常用的避免代码漏洞及系统漏洞的代码模板,然后开发人员需要根据当前开发项目所需实现的功能,进行编写个性化的避免代码漏洞及系统漏洞的代码,然后上传至系统中,系统在接收到用户上传的个性化的避免代码漏洞及系统漏洞的代码,将其复制至对应的避免代码漏洞及系统漏洞的代码模板中,即可自动生成针对当前开发项目的避免所述代码漏洞及系统漏洞的代码,从而预防由于程序设计本身考虑不周而产生的会对程序本身、系统或数据带来潜在危害。In this embodiment, after forming the code template, the user may further input a code specification into the generated code template, where the code specification includes a code vulnerability and a system vulnerability, and the code vulnerability is a common code vulnerability that has been discovered, The latest discovered code vulnerabilities, etc., code vulnerabilities can be manifested in many aspects, the algorithm itself or the code itself may cause code loopholes. The specific manifestations of code vulnerabilities mainly include: (1) The validity of the input data is not checked or checked poorly, or the improper handling of buffer vulnerabilities is caused by this problem. For example, when entering a password, the user may enter a long password. If the program is not restricted, it may cause other problems to be overwritten when the password is stored. (2) Code logic design defects or errors are caused by programmers' care or inconsistency. For example, when there is less leakage condition when judging, when encountering special data, it may lead to unexpected running results of the program. (3) The algorithm's own vulnerability algorithm is the premise of security. The loophole of the algorithm itself may lead to various problems. For example, using a simpler encryption algorithm may easily lead to information leakage, so it is necessary to prevent code vulnerabilities. Specifically, after receiving the code specification input by the user in the generated code template, a common code template for avoiding code vulnerabilities and system vulnerabilities may be extracted in the system, and then the developer needs to perform functions according to the current development project. Write personalized code to avoid code vulnerabilities and system vulnerabilities, and then upload them to the system. The system receives the personalized code to avoid code vulnerabilities and system vulnerabilities uploaded by users, and copies them to corresponding code vulnerabilities and system vulnerabilities. In the code template, the code for avoiding the code vulnerabilities and system vulnerabilities for the current development project can be automatically generated, thereby preventing potential harm to the program itself, the system or the data due to the inconsistency of the programming itself.
本实施例提出的代码生成方法,通过接收用户在生成的代码模板中输入代码规范,其中,所述代码规范包括代码漏洞及系统漏洞;然后根据所述代码规范自动生成避免所述代码漏洞及系统漏洞的代码,从而预防由于程序设计本身考虑不周而产生的会对程序本身、系统或数据带来潜在危害。The code generation method of the embodiment, by receiving a code specification input by a user in a generated code template, wherein the code specification includes a code vulnerability and a system vulnerability; and then automatically generating a code vulnerability and system according to the code specification Vulnerability code to prevent potential harm to the program itself, system or data due to poorly designed programming itself.
进一步地,参照图3,基于本申请代码生成方法第一实施例提出本申请代码生成方法第三实施例。Further, referring to FIG. 3, a third embodiment of the code generating method of the present application is proposed based on the first embodiment of the code generating method of the present application.
在本实施例中,所述步骤S30之后的步骤还包括:In this embodiment, the step after the step S30 further includes:
步骤S60,对生成的代码进行自动测试,并生成测试报告;Step S60, performing automatic testing on the generated code, and generating a test report;
步骤S70,根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新;Step S70, adjusting the code template according to the test report, and updating the adjusted code template;
步骤S80,根据预设的周期对代码模板的使用次数进行统计,生成使用报告,并将所述使用报告作为代码模板生成的参考。 Step S80: Perform statistics on the number of times the code template is used according to a preset period, generate a usage report, and use the usage report as a reference for generating the code template.
在本实施例中,在生成代码之后,可以进一步对生成的代码进行自动测试,测试代码是否有问题,然后生成测试报告,以便用户获知生成的代码是否有问题,如果生成的代码有问题,具体为哪里的代码出现问题,方便用户更改。生成测试报告之后,可以进一步根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新,以使代码模板更加精准。进一步地,还可以根据预设的周期对各个代码模板的使用次数进行统计,生成使用报告,并将所述使用报告作为代码模板生成的参考。In this embodiment, after the code is generated, the generated code may be further tested automatically, whether the test code has a problem, and then a test report is generated, so that the user knows whether the generated code has a problem, and if the generated code has a problem, There is a problem with the code for the user, so that the user can change it. After the test report is generated, the code template can be further adjusted according to the test report, and the adjusted code template is updated to make the code template more precise. Further, the number of times of using each code template may be counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
本实施例提出的代码生成方法,通过对生成的代码进行自动测试,并生成测试报告,以便用户获知生成的代码是否有问题,以及出现问题的具体位置;然后根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新,以使代码模板更加精准;最后可以根据预设的周期对代码模板的使用次数进行统计,生成使用报告,以便将所述使用报告作为代码模板生成的参考。The code generation method proposed in this embodiment automatically tests the generated code and generates a test report, so that the user knows whether the generated code has a problem and the specific location where the problem occurs; and then performs the code template according to the test report. Adjust, and update the adjusted code template to make the code template more accurate; finally, the number of times the code template is used can be counted according to a preset period, and a usage report is generated to generate the usage report as a code template. reference.
进一步地,参照图4,基于本申请代码生成方法第一实施例提出本申请代码生成方法第四实施例。Further, referring to FIG. 4, a fourth embodiment of the code generating method of the present application is proposed based on the first embodiment of the code generating method of the present application.
在本实施例中,所述步骤S10之后的步骤还包括:In this embodiment, the step after the step S10 further includes:
步骤S90,接收用户输入的关键词,根据所述关键词向用户推送代码模板;Step S90, receiving a keyword input by the user, and pushing the code template to the user according to the keyword;
步骤S100,监测用户使用推送的代码模板的先后顺序,根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板。Step S100, monitoring the order in which the user uses the pushed code template, analyzing the relationship between the code templates according to the order in which the user uses the code template, and pushing the associated code template to the user.
在本实施例中,用户除了通过直接输入代码模板路径获得代码模板以外,还可以通过输入开发的软件项目所要实现的功能,以获得代码模板。因此在接收用户输入的关键词之后,可以根据接收到的关键词与保持的代码模板进行匹配,并将匹配到的代码模板向用户推送。同时在用户使用推送的代码模板过程中,可以进一步监测用户使用推送的代码模板的先后顺序,然后根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板,提高用户使用代码模板的体验。In this embodiment, in addition to obtaining the code template by directly inputting the code template path, the user can also obtain the code template by inputting the function to be implemented by the developed software project. Therefore, after receiving the keyword input by the user, the received keyword can be matched with the retained code template, and the matched code template is pushed to the user. At the same time, in the process of using the pushed code template, the user can further monitor the order of the user using the pushed code template, and then analyze the relationship between the code templates according to the order of the user using the code template, and push the associated code template to the user to improve The experience of users using code templates.
本实施例提出的代码生成方法,通过接收用户输入的关键词,即可根据所述关键词向用户推送代码模板;然后监测用户使用推送的代码模板的先后顺序,根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板,提高用户使用代码模板的体验。The code generating method provided in this embodiment can push the code template to the user according to the keyword by receiving the keyword input by the user; and then monitor the order of the user using the pushed code template, according to the order of the user using the code template. Analyze the relationship between each code template, push the associated code template to the user, and improve the user experience of using the code template.
进一步地,参照图5,基于本申请代码生成方法第一至第四任一实施例提出本申请代码生成方法第五实施例。Further, referring to FIG. 5, a fifth embodiment of the code generating method of the present application is proposed based on any one of the first to fourth embodiments of the code generating method of the present application.
在本实施例中,所述步骤S30包括:In this embodiment, the step S30 includes:
步骤S31,获取所述生成所需代码的基本信息在代码模板中的对应位置;Step S31, acquiring a corresponding location of the basic information of the generated required code in the code template;
步骤S32,将所述生成所需代码的基本信息复制至代码模板中的对应位置生成代码。Step S32, copying the basic information for generating the required code to the corresponding location generation code in the code template.
在本实施例中,在接收生成所需代码的基本信息之后,需要分析所述生成所需代码的基本信息在代码模板中的对应位置,以提高生成的代码的准确率,然后将所述生成所需代码的基本信息复制至代码模板中的对应位置即可生成代码。In this embodiment, after receiving the basic information for generating the required code, it is necessary to analyze the corresponding position of the basic information of the generated required code in the code template to improve the accuracy of the generated code, and then generate the The basic information of the required code is copied to the corresponding location in the code template to generate the code.
本申请实施例进一步提供一种代码生成装置,所述装置包括:The embodiment of the present application further provides a code generating apparatus, where the apparatus includes:
抓取模块,用于抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;a capture module, configured to capture a code whose number of repetitions is greater than or equal to a preset value in the code development system, and enter the code whose repetition number is greater than or equal to a preset value into the template system to form a code template;
接收模块,用于接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;a receiving module, configured to receive a code template path input by the user, extract a corresponding code template according to the code template path, and receive a code that the number of repetitions in the development system input by the user is less than a preset value;
复制模块,用于将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。And a copy module, configured to copy the code whose number of repetitions is less than a preset value into the code generated in the extracted code template.
本申请代码生成装置的具体实施例与上述代码生成方法各实施例基本相同,在此不作赘述。The specific embodiment of the code generating apparatus of the present application is substantially the same as the embodiment of the above code generating method, and details are not described herein.
本申请实施例进一步提供一种代码生成器。The embodiment of the present application further provides a code generator.
如图6所示,该代码生成器可以包括:处理器1001,例如CPU,网络接口1002,用户接口1003,存储器1004。这些组件之间的连接通信可以通过通信总线实现。网络接口1002可选的可以包括标准的有线接口(用于连接有线网络)、无线接口(如WI-FI接口、蓝牙接口、红外线接口等,用于连接无线网络)。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口(例如用于连接有线键盘、有线鼠标等)和/或无线接口(例如用于连接无线键盘、无线鼠标)。存储器1004可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1004可选的还可以是独立于前述处理器1001的存储装置。As shown in FIG. 6, the code generator can include a processor 1001, such as a CPU, a network interface 1002, a user interface 1003, and a memory 1004. Connection communication between these components can be achieved via a communication bus. The network interface 1002 may optionally include a standard wired interface (for connecting to a wired network), a wireless interface (such as a WI-FI interface, a Bluetooth interface, an infrared interface, etc. for connecting to a wireless network). The user interface 1003 can include a display, an input unit such as a keyboard, and the optional user interface 1003 can also include a standard wired interface (eg, for connecting a wired keyboard, a wired mouse, etc.) and/or a wireless interface (eg, Used to connect a wireless keyboard, wireless mouse). The memory 1004 may be a high speed RAM memory or a stable memory (non-volatile) Memory), such as disk storage. The memory 1004 can also optionally be a storage device independent of the aforementioned processor 1001.
本领域技术人员可以理解,图6中示出的代码生成器结构并不构成对代码生成器的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。It will be understood by those skilled in the art that the code generator structure shown in FIG. 6 does not constitute a limitation to the code generator, and may include more or less components than those illustrated, or combine some components or different components. Arrangement.
如图6所示,作为一种计算机存储介质的存储器1002中可以包括操作系统以及代码生成器程序。其中,操作系统是管理和代码生成器的硬件与软件资源的程序,支持代码生成器程序及其他软件或程序的运行。As shown in FIG. 6, an operating system and a code generator program may be included in the memory 1002 as a computer storage medium. Among them, the operating system is a program that manages the hardware and software resources of the code generator, and supports the running of the code generator program and other software or programs.
在图6所示的代码生成器中,处理器1001可以用于执行存储器1002中存储的代码生成程序,以实现以下步骤:In the code generator shown in FIG. 6, the processor 1001 can be used to execute a code generation program stored in the memory 1002 to implement the following steps:
抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;Grab the code in the code development system that the number of repetitions is greater than or equal to the preset value, and enter the code whose repetition number is greater than or equal to the preset value into the template system to form a code template;
接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;Receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code that the number of repetitions in the development system input by the user is less than a preset value;
将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。Copying the code whose number of repetitions is less than the preset value to the code generated in the extracted code template.
进一步地,处理器1001还可以执行存储器1002中存储的代码生成程序,以实现以下步骤:Further, the processor 1001 can also execute a code generation program stored in the memory 1002 to implement the following steps:
接收用户在形成的代码模板中输入的代码规范,其中,所述代码规范包括代码漏洞及系统漏洞;Receiving a code specification entered by a user in a formed code template, wherein the code specification includes a code vulnerability and a system vulnerability;
根据所述代码规范自动生成避免所述代码漏洞及系统漏洞的代码。Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
进一步地,处理器1001还可以执行存储器1002中存储的代码生成程序,以实现以下步骤:Further, the processor 1001 can also execute a code generation program stored in the memory 1002 to implement the following steps:
对生成的代码进行自动测试,并生成测试报告;Automatically test the generated code and generate a test report;
根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新;Adjusting the code template according to the test report, and updating the adjusted code template;
根据预设的周期对代码模板的使用次数进行统计,生成使用报告,并将所述使用报告作为代码模板生成的参考。 The number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
进一步地,处理器1001还可以执行存储器1002中存储的代码生成程序,以实现以下步骤:Further, the processor 1001 can also execute a code generation program stored in the memory 1002 to implement the following steps:
接收用户输入的关键词,根据所述关键词向用户推送代码模板;Receiving a keyword input by the user, and pushing the code template to the user according to the keyword;
监测用户使用推送的代码模板的先后顺序,根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板。The user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
进一步地,处理器1001还可以执行存储器1002中存储的代码生成程序,以实现以下步骤:Further, the processor 1001 can also execute a code generation program stored in the memory 1002 to implement the following steps:
获取所述重复次数小于预设值的代码在代码模板中的对应位置;Obtaining a corresponding position of the code whose number of repetitions is less than a preset value in the code template;
将所述重复次数小于预设值的代码复制至代码模板中的对应位置生成代码。Copying the code whose number of repetitions is less than the preset value to the corresponding location generation code in the code template.
本申请代码生成器的具体实施例与上述代码生成方法各实施例基本相同,在此不作赘述。The specific embodiment of the code generator of the present application is substantially the same as the embodiment of the code generation method described above, and details are not described herein.
本申请提供了一种计算机可读存储介质,所述计算机可读存储介质存储有一个或者多个程序,所述一个或者多个程序可被一个或者多个处理器执行,以实现以下步骤:The application provides a computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the following steps:
抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;Grab the code in the code development system that the number of repetitions is greater than or equal to the preset value, and enter the code whose repetition number is greater than or equal to the preset value into the template system to form a code template;
接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;Receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code that the number of repetitions in the development system input by the user is less than a preset value;
将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。Copying the code whose number of repetitions is less than the preset value to the code generated in the extracted code template.
进一步地,所述一个或者多个程序可被所述一个或者多个处理器执行,还实现以下步骤:Further, the one or more programs may be executed by the one or more processors, and the following steps are also implemented:
接收用户在形成的代码模板中输入的代码规范,其中,所述代码规范包括代码漏洞及系统漏洞;Receiving a code specification entered by a user in a formed code template, wherein the code specification includes a code vulnerability and a system vulnerability;
根据所述代码规范自动生成避免所述代码漏洞及系统漏洞的代码。Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
进一步地,所述一个或者多个程序可被所述一个或者多个处理器执行,还实现以下步骤:Further, the one or more programs may be executed by the one or more processors, and the following steps are also implemented:
对生成的代码进行自动测试,并生成测试报告;Automatically test the generated code and generate a test report;
根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新;Adjusting the code template according to the test report, and updating the adjusted code template;
根据预设的周期对代码模板的使用次数进行统计,生成使用报告,并将所述使用报告作为代码模板生成的参考。 The number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
进一步地,所述一个或者多个程序可被所述一个或者多个处理器执行,还实现以下步骤:Further, the one or more programs may be executed by the one or more processors, and the following steps are also implemented:
接收用户输入的关键词,根据所述关键词向用户推送代码模板;Receiving a keyword input by the user, and pushing the code template to the user according to the keyword;
监测用户使用推送的代码模板的先后顺序,根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板。The user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
进一步地,所述一个或者多个程序可被所述一个或者多个处理器执行,还实现以下步骤:Further, the one or more programs may be executed by the one or more processors, and the following steps are also implemented:
获取所述重复次数小于预设值的代码在代码模板中的对应位置;Obtaining a corresponding position of the code whose number of repetitions is less than a preset value in the code template;
将所述重复次数小于预设值的代码复制至代码模板中的对应位置生成代码。Copying the code whose number of repetitions is less than the preset value to the corresponding location generation code in the code template.
本申请计算机可读存储介质的具体实施例与上述代码生成方法和代码生成方法器各实施例基本相同,在此不作赘述。The specific embodiment of the computer readable storage medium of the present application is substantially the same as the foregoing embodiment of the code generation method and the code generation method, and is not described herein.
还需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It is also to be understood that the term "comprises", "comprising", or any other variants thereof is intended to encompass a non-exclusive inclusion, such that a process, method, article, or device that comprises a And also includes other elements not explicitly listed, or elements that are inherent to such a process, method, item, or device. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device that comprises the element.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better. Implementation. Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk, The optical disc includes a number of instructions for causing a terminal device (which may be a cell phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods of various embodiments of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above is only a preferred embodiment of the present application, and is not intended to limit the scope of the patent application, and the equivalent structure or equivalent process transformations made by the specification and the drawings of the present application, or directly or indirectly applied to other related technical fields. The same is included in the scope of patent protection of this application.

Claims (20)

  1. 一种代码生成方法,其特征在于,所述方法包括以下步骤: A code generation method, characterized in that the method comprises the following steps:
    抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;Grab the code in the code development system that the number of repetitions is greater than or equal to the preset value, and enter the code whose repetition number is greater than or equal to the preset value into the template system to form a code template;
    接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;Receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code that the number of repetitions in the development system input by the user is less than a preset value;
    将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。Copying the code whose number of repetitions is less than the preset value to the code generated in the extracted code template.
  2. 如权利要求1所述的代码生成方法,其特征在于,所述抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到系统中,形成代码模板的步骤之后还包括:The code generating method according to claim 1, wherein the code in the crawl code development system repeats a number of times greater than or equal to a preset value, and the code whose number of repetitions is greater than or equal to a preset value is entered into In the system, after the step of forming a code template, the method further includes:
    接收用户在形成的代码模板中输入的代码规范,其中,所述代码规范包括代码漏洞及系统漏洞;Receiving a code specification entered by a user in a formed code template, wherein the code specification includes a code vulnerability and a system vulnerability;
    根据所述代码规范自动生成避免所述代码漏洞及系统漏洞的代码。Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
  3. 如权利要求1所述的代码生成方法,其特征在于,所述将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码的步骤之后还包括:The code generating method according to claim 1, wherein the step of copying the code whose number of repetitions is less than a preset value to the code generated in the extracted code template further comprises:
    对生成的代码进行自动测试,并生成测试报告;Automatically test the generated code and generate a test report;
    根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新;Adjusting the code template according to the test report, and updating the adjusted code template;
    根据预设的周期对代码模板的使用次数进行统计,生成使用报告,并将所述使用报告作为代码模板生成的参考。 The number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
  4. 如权利要求1所述的代码生成方法,其特征在于,所述抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到系统中,形成代码模板的步骤之后还包括:The code generating method according to claim 1, wherein the code in the crawl code development system repeats a number of times greater than or equal to a preset value, and the code whose number of repetitions is greater than or equal to a preset value is entered into In the system, after the step of forming a code template, the method further includes:
    接收用户输入的关键词,根据所述关键词向用户推送代码模板;Receiving a keyword input by the user, and pushing the code template to the user according to the keyword;
    监测用户使用推送的代码模板的先后顺序,根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板。The user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
  5. 如权利要求1所述的代码生成方法,其特征在于,所述将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码的步骤包括:The code generating method according to claim 1, wherein the step of copying the code whose number of repetitions is less than a preset value to the code generated in the extracted code template comprises:
    获取所述重复次数小于预设值的代码在代码模板中的对应位置;Obtaining a corresponding position of the code whose number of repetitions is less than a preset value in the code template;
    将所述重复次数小于预设值的代码复制至代码模板中的对应位置生成代码。Copying the code whose number of repetitions is less than the preset value to the corresponding location generation code in the code template.
  6. 一种代码生成装置,其特征在于,所述装置包括:A code generating device, characterized in that the device comprises:
    抓取模块,用于抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;a capture module, configured to capture a code whose number of repetitions is greater than or equal to a preset value in the code development system, and enter the code whose repetition number is greater than or equal to a preset value into the template system to form a code template;
    接收模块,用于接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;a receiving module, configured to receive a code template path input by the user, extract a corresponding code template according to the code template path, and receive a code that the number of repetitions in the development system input by the user is less than a preset value;
    复制模块,用于将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。And a copy module, configured to copy the code whose number of repetitions is less than a preset value into the code generated in the extracted code template.
  7. 如权利要求6所述的代码生成装置,其特征在于,所述装置还包括:The code generating apparatus according to claim 6, wherein the apparatus further comprises:
    接收模块,用于接收用户在形成的代码模板中输入的代码规范,其中,所述代码规范包括代码漏洞及系统漏洞;a receiving module, configured to receive a code specification input by a user in a formed code template, where the code specification includes a code vulnerability and a system vulnerability;
    生成模块,用于根据所述代码规范自动生成避免所述代码漏洞及系统漏洞的代码。A generating module for automatically generating code to avoid the code vulnerability and system vulnerability according to the code specification.
  8. 如权利要求6所述的代码生成装置,其特征在于,装置还包括:The code generating apparatus according to claim 6, wherein the apparatus further comprises:
    自动测试模块,用于对生成的代码进行自动测试,并生成测试报告;An automatic test module for automatically testing the generated code and generating a test report;
    调整模块,用于根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新;An adjustment module, configured to adjust the code template according to the test report, and update the adjusted code template;
    统计模块,用于 根据预设的周期对代码模板的使用次数进行统计,生成使用报告,并将所述使用报告作为代码模板生成的参考。Statistics module for The number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
  9. 如权利要求6所述的代码生成装置,其特征在于,所述接收模块还用于:The code generating apparatus according to claim 6, wherein the receiving module is further configured to:
    接收用户输入的关键词,根据所述关键词向用户推送代码模板;Receiving a keyword input by the user, and pushing the code template to the user according to the keyword;
    所述装置还包括:The device also includes:
    监测模块,用于监测用户使用推送的代码模板的先后顺序,根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板。The monitoring module is configured to monitor the sequence of the user using the pushed code template, analyze the relationship between the code templates according to the order in which the user uses the code template, and push the associated code template to the user.
  10. 如权利要求6所述的代码生成装置,其特征在于,所述复制模块包括:The code generating apparatus according to claim 6, wherein said copying module comprises:
    获取单元,用于获取所述重复次数小于预设值的代码在代码模板中的对应位置;An obtaining unit, configured to acquire a corresponding position of the code whose number of repetitions is less than a preset value in a code template;
    复制单元,用于将所述重复次数小于预设值的代码复制至代码模板中的对应位置生成代码。And a copying unit, configured to copy the code whose number of repetitions is less than a preset value to a corresponding location generation code in the code template.
  11. 一种代码生成器,其特征在于,所述代码生成器包括处理器及存储器,所述存储器中存储有代码生成程序;所述处理器用于执行所述代码生成程序,以实现以下步骤:A code generator, comprising: a processor and a memory, wherein the memory stores a code generation program; the processor is configured to execute the code generation program to implement the following steps:
    抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;Grab the code in the code development system that the number of repetitions is greater than or equal to the preset value, and enter the code whose repetition number is greater than or equal to the preset value into the template system to form a code template;
    接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;Receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code that the number of repetitions in the development system input by the user is less than a preset value;
    将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。Copying the code whose number of repetitions is less than the preset value to the code generated in the extracted code template.
  12. 如权利要求11所述的代码生成器,其特征在于,所述处理器还用于执行所述代码生成程序,以实现以下步骤:The code generator according to claim 11, wherein said processor is further configured to execute said code generating program to implement the following steps:
    接收用户在形成的代码模板中输入代码规范,其中,所述代码规范包括代码漏洞及系统漏洞;The receiving user enters a code specification in the formed code template, wherein the code specification includes a code vulnerability and a system vulnerability;
    根据所述代码规范自动生成避免所述代码漏洞及系统漏洞的代码。Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
  13. 如权利要求11所述的代码生成器,其特征在于,所述处理器还用于执行所述代码生成程序,以实现以下步骤:The code generator according to claim 11, wherein said processor is further configured to execute said code generating program to implement the following steps:
    对生成的代码进行自动测试,并生成测试报告;Automatically test the generated code and generate a test report;
    根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新;Adjusting the code template according to the test report, and updating the adjusted code template;
    根据预设的周期对代码模板的使用次数进行统计,生成使用报告,并将所述使用报告作为代码模板生成的参考。The number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
  14. 如权利要求11所述的代码生成器,其特征在于,所述处理器还用于执行所述代码生成程序,以实现以下步骤:The code generator according to claim 11, wherein said processor is further configured to execute said code generating program to implement the following steps:
    接收用户输入的关键词,根据所述关键词向用户推送代码模板;Receiving a keyword input by the user, and pushing the code template to the user according to the keyword;
    监测用户使用推送的代码模板的先后顺序,根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板。The user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
  15. 如权利要求11所述的代码生成器,其特征在于,所述处理器还用于执行所述代码生成程序,以实现以下步骤:The code generator according to claim 11, wherein said processor is further configured to execute said code generating program to implement the following steps:
    获取所述重复次数小于预设值的代码在代码模板中的对应位置;Obtaining a corresponding position of the code whose number of repetitions is less than a preset value in the code template;
    将所述重复次数小于预设值的代码复制至代码模板中的对应位置生成代码。Copying the code whose number of repetitions is less than the preset value to the corresponding location generation code in the code template.
  16. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有代码生成程序,所述代码生成程序被处理器执行时实现如下步骤:A computer readable storage medium, wherein the computer readable storage medium stores a code generation program, and when the code generation program is executed by the processor, the following steps are implemented:
    抓取代码开发系统中重复次数大于或等于预设值的代码,并将所述重复次数大于或等于预设值的代码录入到模板系统中,形成代码模板;Grab the code in the code development system that the number of repetitions is greater than or equal to the preset value, and enter the code whose repetition number is greater than or equal to the preset value into the template system to form a code template;
    接收用户输入的代码模板路径,根据所述代码模板路径,提取对应的代码模板,接收用户输入的开发系统中重复次数小于预设值的代码;Receiving a code template path input by the user, extracting a corresponding code template according to the code template path, and receiving a code that the number of repetitions in the development system input by the user is less than a preset value;
    将所述重复次数小于预设值的代码复制至提取到的代码模板中生成代码。Copying the code whose number of repetitions is less than the preset value to the code generated in the extracted code template.
  17. 如权利要求16所述的计算机可读存储介质,其特征在于,所述一个或者多个程序可被一个或者多个处理器执行,还实现以下步骤:The computer readable storage medium of claim 16 wherein said one or more programs are executable by one or more processors and further implementing the steps of:
    接收用户在形成的代码模板中输入的代码规范,其中,所述代码规范包括代码漏洞及系统漏洞;Receiving a code specification entered by a user in a formed code template, wherein the code specification includes a code vulnerability and a system vulnerability;
    根据所述代码规范自动生成避免所述代码漏洞及系统漏洞的代码。Code that avoids the code vulnerabilities and system vulnerabilities is automatically generated according to the code specification.
  18. 如权利要求16所述的计算机可读存储介质,其特征在于,所述一个或者多个程序可被一个或者多个处理器执行,还实现以下步骤:The computer readable storage medium of claim 16 wherein said one or more programs are executable by one or more processors and further implementing the steps of:
    对生成的代码进行自动测试,并生成测试报告;Automatically test the generated code and generate a test report;
    根据所述测试报告对代码模板进行调整,并且将调整后的代码模板进行更新;Adjusting the code template according to the test report, and updating the adjusted code template;
    根据预设的周期对代码模板的使用次数进行统计,生成使用报告,并将所述使用报告作为代码模板生成的参考。The number of times the code template is used is counted according to a preset period, a usage report is generated, and the usage report is used as a reference for generating the code template.
  19. 如权利要求16所述的计算机可读存储介质,其特征在于,所述一个或者多个程序可被一个或者多个处理器执行,还实现以下步骤:The computer readable storage medium of claim 16 wherein said one or more programs are executable by one or more processors and further implementing the steps of:
    接收用户输入的关键词,根据所述关键词向用户推送代码模板;Receiving a keyword input by the user, and pushing the code template to the user according to the keyword;
    监测用户使用推送的代码模板的先后顺序,根据用户使用代码模板的先后顺序分析各代码模板间的关系,向用户推送关联的代码模板。 The user is monitored by the sequence of the pushed code templates, and the relationship between the code templates is analyzed according to the order in which the user uses the code templates, and the associated code templates are pushed to the user.
  20. 如权利要求16所述的计算机可读存储介质,其特征在于,所述一个或者多个程序可被一个或者多个处理器执行,还实现以下步骤:The computer readable storage medium of claim 16 wherein said one or more programs are executable by one or more processors and further implementing the steps of:
    获取所述重复次数小于预设值的代码在代码模板中的对应位置;Obtaining a corresponding position of the code whose number of repetitions is less than a preset value in the code template;
    将所述重复次数小于预设值的代码复制至代码模板中的对应位置生成代码。 Copying the code whose number of repetitions is less than the preset value to the corresponding location generation code in the code template.
PCT/CN2018/083942 2017-08-01 2018-04-20 Code generation method and apparatus, code generator and readable storage medium WO2019024543A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710656395.4 2017-08-01
CN201710656395.4A CN108345453A (en) 2017-08-01 2017-08-01 Code generating method, code generator and readable storage medium storing program for executing

Publications (1)

Publication Number Publication Date
WO2019024543A1 true WO2019024543A1 (en) 2019-02-07

Family

ID=62963215

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/083942 WO2019024543A1 (en) 2017-08-01 2018-04-20 Code generation method and apparatus, code generator and readable storage medium

Country Status (2)

Country Link
CN (1) CN108345453A (en)
WO (1) WO2019024543A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109254774A (en) * 2018-08-30 2019-01-22 郑州云海信息技术有限公司 The management method and device of code in software development system
CN109255059A (en) * 2018-08-31 2019-01-22 平安科技(深圳)有限公司 Product basic algorithm determines method, apparatus, computer equipment and storage medium
CN109375943A (en) * 2018-10-18 2019-02-22 中国银行股份有限公司 A kind of program file generation method and device
CN110688103B (en) * 2019-10-10 2023-07-04 望海康信(北京)科技股份公司 Code writing method, device, electronic equipment and computer readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080313605A1 (en) * 2007-06-14 2008-12-18 Motorola, Inc. Development framework for automated data throughput optimization
CN103150165A (en) * 2013-03-07 2013-06-12 中国农业大学 Frame and method for building outdoor data acquisition program
CN104267966A (en) * 2014-10-15 2015-01-07 北京国双科技有限公司 Method and device for generating program codes of software
CN106354492A (en) * 2016-08-23 2017-01-25 深圳Tcl智能家庭科技有限公司 Automatic code generation method and system capable of rapidly adjusting transaction process connection
CN106469064A (en) * 2016-09-04 2017-03-01 深圳市云智易联科技有限公司 Code generating method and code generating unit

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7392504B2 (en) * 2002-06-06 2008-06-24 International Business Machines Corporation System and method for automated source code generation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080313605A1 (en) * 2007-06-14 2008-12-18 Motorola, Inc. Development framework for automated data throughput optimization
CN103150165A (en) * 2013-03-07 2013-06-12 中国农业大学 Frame and method for building outdoor data acquisition program
CN104267966A (en) * 2014-10-15 2015-01-07 北京国双科技有限公司 Method and device for generating program codes of software
CN106354492A (en) * 2016-08-23 2017-01-25 深圳Tcl智能家庭科技有限公司 Automatic code generation method and system capable of rapidly adjusting transaction process connection
CN106469064A (en) * 2016-09-04 2017-03-01 深圳市云智易联科技有限公司 Code generating method and code generating unit

Also Published As

Publication number Publication date
CN108345453A (en) 2018-07-31

Similar Documents

Publication Publication Date Title
WO2019024543A1 (en) Code generation method and apparatus, code generator and readable storage medium
WO2019024219A1 (en) Automatic document generation method and apparatus, automatic document generator and medium
WO2018188342A1 (en) Method, apparatus and device for generating script file, and computer-readable storage medium
WO2018107610A1 (en) Service data processing method, system and device, and computer-readable storage medium
WO2018120429A1 (en) Resource update method, terminal, computer readable storage medium and resource update device
WO2017143692A1 (en) Smart television and voice control method therefor
WO2018120457A1 (en) Data processing method, apparatus, device, and computer readable storage medium
WO2018149299A1 (en) Method of identifying social insurance fraud, device, apparatus, and computer storage medium
WO2018149190A1 (en) Component debugging method, device and apparatus, and computer readable storage medium
WO2019037396A1 (en) Account clearing method, device and equipment and storage medium
WO2015158297A1 (en) Method, apparatus, and system for controlling delivery task in social networking platform
WO2019000800A1 (en) Credential preparation method, apparatus, and device and computer readable storage medium
WO2015158219A1 (en) Remote debugging method and apparatus for mobile terminal
WO2019104876A1 (en) Insurance product pushing method and system, terminal, client terminal, and storage medium
WO2017148112A1 (en) Fingerprint entry method, and terminal
WO2018149300A1 (en) Disease probability detection method, apparatus and device, and computer readable storage medium
WO2019100531A1 (en) Digital signature generation method and device thereof, verification method and device thereof, and storage medium
WO2018076569A1 (en) Electronic control unit-based program flashing method and apparatus
WO2019041851A1 (en) Home appliance after-sales consulting method, electronic device and computer-readable storage medium
WO2018188196A1 (en) Data version control method, data version controller, device and computer-readable storage medium
WO2019169814A1 (en) Method, apparatus and device for automatically generating chinese annotation, and storage medium
WO2019000801A1 (en) Data synchronization method, apparatus, and device, and computer readable storage medium
WO2023153818A1 (en) Method of providing neural network model and electronic apparatus for performing the same
WO2019000466A1 (en) Face recognition method and apparatus, storage medium, and electronic device
WO2017032122A1 (en) Method and apparatus for detecting digital television set

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18842394

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18842394

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 04.08.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18842394

Country of ref document: EP

Kind code of ref document: A1