Code packaging method and related device

By adjusting and encapsulating the similarity threshold of the existing module's code, a module that meets new needs is generated, which solves the problems of poor closedness and low reusability of business codes in the prior art, and improves the code packaging efficiency.

CN119690443APending Publication Date: 2025-03-25MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411399865.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-08
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

In the prior art, the business code has poor enclosure, resulting in inability to reuse and low code encapsulation efficiency.

Method used

By determining the requirements of the module to be generated and adjusting and encapsulating the code of the existing module based on the similarity threshold, modules that meet new requirements are generated.

Benefits of technology

It improves the reuse rate and enclosure of modules, reduces the need to fully construct code according to business needs, and improves the efficiency of code packaging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690443A_ABST
    Figure CN119690443A_ABST
Patent Text Reader

Abstract

The invention provides a code packaging method and a related device. The method comprises the steps of determining a first module demand of a to-be-generated module, and determining a second existing module from first existing modules based on the first module demand; under the condition that the similarity between the first module demand and a second module demand of a second existing module is larger than a first similarity threshold value and smaller than a second similarity threshold value, the code of the second existing module is adjusted, the adjusted code of the second existing module is obtained, and the first similarity threshold value is smaller than the second similarity threshold value; determining a packaging mode corresponding to the category of the second existing module; and packaging the adjusted code of the second existing module according to the packaging mode to obtain a module meeting the requirements of the first module. According to the method and the device, the reuse rate of the module and the code packaging efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to computer technology, and in particular to a code packaging method and related devices. Background Art

[0002] Code encapsulation technology is a technology that combines data and methods of operating these data. It is used to improve the security of the code. By limiting direct access to the internal state of the object, it prevents improper operation of external code, making the code easier to manage and maintain. The encapsulated code can be regarded as an independent unit, hiding the implementation process of the code and exposing only an interface accessed by the outside world. Summary of the invention

[0003] The embodiments of the present application provide a code encapsulation method and related devices, which can improve the reuse rate of modules and the efficiency of code encapsulation.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] The present application provides a code packaging method, the method comprising:

[0006] Determine a first module requirement of a module to be generated, and determine a second existing module from the first existing module based on the first module requirement;

[0007] When the similarity between the first module requirement and the second module requirement of the second existing module is greater than a first similarity threshold and less than a second similarity threshold, adjusting the code of the second existing module to obtain an adjusted code of the second existing module, and the first similarity threshold is less than the second similarity threshold;

[0008] Determine a packaging method corresponding to the category of the second existing module;

[0009] The adjusted code of the second existing module is packaged according to the packaging method to obtain the module that meets the requirements of the first module.

[0010] The present application provides a code packaging device, including:

[0011] a code determination module, configured to determine a first module requirement of a module to be generated, and determine a second existing module from a first existing module based on the first module requirement; and when the similarity between the first module requirement and the second module requirement of the second existing module is greater than a first similarity threshold and less than a second similarity threshold, adjust the code of the second existing module to obtain an adjusted code of the second existing module, and the first similarity threshold is less than the second similarity threshold;

[0012] A code encapsulation module is used to determine an encapsulation method corresponding to the category of the second existing module; encapsulate the adjusted code of the second existing module according to the encapsulation method to obtain the module that meets the requirements of the first module.

[0013] An embodiment of the present application provides an electronic device, including:

[0014] A memory for storing computer executable instructions;

[0015] The processor is used to implement the code encapsulation method provided in the embodiment of the present application when executing the computer executable instructions stored in the memory.

[0016] An embodiment of the present application provides a computer-readable storage medium storing a computer program or computer-executable instructions for implementing the code encapsulation method provided in the embodiment of the present application when executed by a processor.

[0017] An embodiment of the present application provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, the code encapsulation method provided in the embodiment of the present application is implemented.

[0018] The embodiments of the present application have the following beneficial effects:

[0019] Based on the first module requirement, a second existing module is determined from the first existing module. When the similarity between the first module requirement and the second module requirement of the second existing module is greater than a first similarity threshold and less than a second similarity threshold, the code of the second existing module is adjusted to obtain the adjusted code of the second existing module, and the adjusted code of the second existing module is encapsulated in a packaging method corresponding to the category of the second existing module to obtain a module that meets the first module requirement. By encapsulating the adjusted code of the second existing module, the encapsulated code is no longer modified, which can improve the closedness of the module and the reuse rate of the module. At the same time, by comparing the similarity between the module requirements, the code is adjusted after the similarity condition is met, thereby avoiding the full construction of the code according to the business requirements and improving the efficiency of code encapsulation. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It is a schematic diagram of the architecture of the code packaging system provided in the embodiment of the present application;

[0021] Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0022] Figure 3A It is a first flow chart of the code packaging method provided in an embodiment of the present application;

[0023] Figure 3B It is a second flow chart of the code packaging method provided in an embodiment of the present application;

[0024] Figure 3C 3 is a schematic diagram of a third flow chart of the code packaging method provided in an embodiment of the present application;

[0025] Figure 3D is a fourth flow chart of the code packaging method provided in an embodiment of the present application;

[0026] Figure 3E is a fifth flow chart of the code packaging method provided in an embodiment of the present application;

[0027] Figure 3F 6 is a schematic diagram of a code packaging method according to an embodiment of the present application;

[0028] Figure 4 It is a code encapsulation flow chart provided in the embodiment of the present application;

[0029] Figure 5 is a schematic diagram of a behavioral interface provided in an embodiment of the present application;

[0030] Figure 6 It is a flow chart of risk control business handling provided by the embodiment of the present application;

[0031] Figure 7 It is a business evolution flowchart provided in an embodiment of the present application.

[0032] It should be pointed out that the above-mentioned "first" and "second" are only used to distinguish different solutions, and do not represent the degree of superiority or inferiority of the solutions or the priority in the implementation process. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0034] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0035] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0036] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0037] The relevant data collection and processing in the embodiments of this application should be strictly in accordance with the requirements of relevant national laws and regulations when applied in examples, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of authorization of laws and regulations and the personal information subject.

[0038] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0039] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0040] 1) Module is a class or object that encapsulates data and methods for operating these data. Modules have the characteristics of encapsulation, abstraction and reusability. Encapsulation is used to indicate that the module hides its internal implementation details and only exposes an interface that can be accessed by the outside world. Abstraction is used to indicate that the module provides a simplified interface so that users can use the module's functions without understanding the module's internal structure. Reusability is used to indicate that the module can be reused in different programs.

[0041] 2) Module requirements are specific requirements that the module needs to meet. The requirements that the module needs to meet can be functional requirements, performance requirements, interface requirements, etc. Among them, functional requirements are specific functions or tasks that the module must perform; performance requirements are specific performance indicators that the module must meet while meeting the functional requirements, such as response time, throughput, resource utilization, etc.; interface requirements are communication protocols and data format requirements that the module must comply with when interacting with other modules.

[0042] In the related art, existing business codes are often modified, with poor closure, and the boundaries between different business codes are fuzzy and highly coupled, making it impossible to reuse existing business codes. To address the above problems, the embodiments of the present application provide a code encapsulation method, device, electronic device, computer-readable storage medium, and computer program product, which can improve the reuse rate of modules and the efficiency of code encapsulation.

[0043] The code encapsulation method described in the embodiments of the present application can be applied to various fields, for example, user order processing, inventory management and other fields. That is, the code encapsulation method described in the embodiments of the present application is not limited to a certain field.

[0044] The following describes an exemplary application of the electronic device provided in the embodiment of the present application. The device provided in the embodiment of the present application can be implemented as a terminal or a server. The following describes an exemplary application when the device is implemented as a server.

[0045] See also Figure 1 , Figure 1 It is an architectural diagram of the code encapsulation system 100 provided in an embodiment of the present application. To support a code encapsulation application, a terminal (terminal 400 is shown as an example) is connected to a server 200 via a network 300. The network 300 may be a wide area network or a local area network, or a combination of the two.

[0046] The terminal 400 is used to send the first module requirement of the module to be generated to the server 200 through the network 300. The server 200 is used to determine the second existing module from the first existing module based on the first module requirement. When the similarity between the first module requirement and the second module requirement of the second existing module is greater than the first similarity threshold and less than the second similarity threshold, the code of the second existing module is adjusted to obtain the adjusted code of the second existing module, and the encapsulation method corresponding to the category of the second existing module is determined. The code of the adjusted second existing module is encapsulated according to the encapsulation method to obtain a module that meets the first module requirement. The code of the module that meets the first module requirement is returned to the terminal 400. The terminal 400 displays the code of the module that meets the first module requirement through the graphical interface 410.

[0047] An example of code encapsulation performed by the terminal 400 is described below.

[0048] In some embodiments, the terminal 400 can independently complete the code packaging task. For example, the terminal 400 is used to determine the first module requirement of the module to be generated, and based on the first module requirement, determine the second existing module from the first existing module. When the similarity between the first module requirement and the second module requirement of the second existing module is greater than the first similarity threshold and less than the second similarity threshold, the code of the second existing module is adjusted to obtain the adjusted code of the second existing module, determine the packaging method corresponding to the category of the second existing module, and package the adjusted code of the second existing module according to the packaging method to obtain a module that meets the first module requirement. The code of the module that meets the first module requirement is displayed through the graphical interface 410.

[0049] In one implementation scenario, the server or terminal can encapsulate the code under the user order business scenario, determine the order generation requirement of the order generation module for prop A to be generated, and based on the order generation requirement, determine the second existing module (such as the order generation module for prop B) from the first existing module (such as the order generation module for prop B, the manual entry module), and when the similarity between the order generation requirement and the module requirement for generating an order for prop B of the second existing module is greater than the first similarity threshold and less than the second similarity threshold, adjust the order generation code for prop B of the second existing module to obtain the order generation code for prop A, determine the packaging method corresponding to the automatic processing category of the second existing module, and encapsulate the order generation code for prop A according to the packaging method to obtain the order generation module for prop A that satisfies the order generation requirement for prop A.

[0050] In one implementation scenario, the server or terminal can encapsulate the code in the inventory management scenario, determine the outbound demand of the outbound module for goods A to be generated, and based on the outbound demand, determine the second existing module (such as the outbound module for goods B, the manual entry module) from the first existing module (such as the outbound module for goods B), and when the similarity between the outbound demand and the module demand for outbound delivery of goods B of the second existing module is greater than the first similarity threshold and less than the second similarity threshold, adjust the outbound code for goods B of the second existing module to obtain the outbound code for goods A, determine the packaging method corresponding to the automatic processing category of the second existing module, and package the outbound code for goods A according to the packaging method to obtain the outbound module for goods A that meets the requirements for outbound delivery of goods A.

[0051] In some embodiments, server 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.

[0052] The terminal 400 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.

[0053] See also Figure 2 , Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, Figure 2 The electronic device 500 shown may be Figure 1 In the terminal 400 or server 200, the electronic device 500 includes: at least one processor 510, a memory 550, and at least one network interface 520. The various components in the server 200 are coupled together through a bus system 540. It can be understood that the bus system 540 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 540 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in Figure 2 Various buses are labeled as bus system 540 .

[0054] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0055] The user interface 530 includes one or more output devices 531 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls;

[0056] In some embodiments, when the terminal 400 independently completes the code packaging task, the server 200 provided by the embodiment of the present application does not include the user interface 530 .

[0057] The memory 550 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, a hard disk drive, an optical disk drive, etc. The memory 550 may optionally include one or more storage devices that are physically located away from the processor 510.

[0058] The memory 550 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 550 described in the embodiments of the present application is intended to include any suitable type of memory.

[0059] In some embodiments, the memory 550 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.

[0060] Operating system 551, including system programs for processing various basic system services and performing hardware-related tasks, such as framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;

[0061] A network communication module 552, for reaching other computing devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 include: Bluetooth, Wireless Compatibility Certification (WiFi), and Universal Serial Bus (USB);

[0062] a presentation module 553 for enabling presentation of information via one or more output devices 531 (e.g., display screen, speaker, etc.) associated with the user interface 530 (e.g., a user interface for operating peripherals and displaying content and information);

[0063] In some embodiments, when the code packaging task is completed independently by the terminal 400, the server 200 provided in the embodiment of the present application may not include the presentation module 553.

[0064] The input processing module 554 is used to detect one or more user inputs or interactions from one of the one or more input devices 532 and translate the detected inputs or interactions; in some embodiments, when the embodiment completes the code encapsulation task independently by the terminal 400, the server 200 provided in the embodiment of the present application may not include the presentation module 553.

[0065] In some embodiments, the device provided in the embodiments of the present application can be implemented in software. Figure 2 The code encapsulation device 555 stored in the memory 550 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: a code determination module 5551 and a code encapsulation module 5552. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.

[0066] It should be noted that in the example of code encapsulation below, those skilled in the art may apply the code encapsulation method provided in the embodiment of the present application to code encapsulation based on their understanding of the following.

[0067] See also Figure 3A , Figure 3A This is a first flow chart of the code encapsulation method provided in the embodiment of the present application, which will be combined with Figure 3A The steps shown are used for illustration. The code encapsulation method provided in the embodiment of the present application can be implemented by a server or a terminal alone, or by a server and a terminal in collaboration. The following will take the collaborative implementation by a server and a terminal as an example for illustration.

[0068] In step 101 , a first module requirement of a module to be generated is determined, and based on the first module requirement, a second existing module is determined from a first existing module.

[0069] Here, the module to be generated is a module that is being considered or planned for development. The embodiment of the present application does not limit the specific structure of the module. The structure of the module can be a collection of multiple encapsulation functions. The category of the module can be a conditional branch category, a parallel branch category, a manual business category, and an automatic business category, etc. Each category corresponds to at least one encapsulation function. The encapsulation function corresponding to the conditional branch category is used to implement the module requirements for conditional judgment, and the encapsulation function corresponding to the parallel branch category is used to implement the module requirements for parallel processing. Taking obtaining the user's preferences as an example, the user likes traveling and reading at the same time. After processing the encapsulation function for obtaining the user's preferences, it jumps to the encapsulation function about traveling and the encapsulation function about reading in parallel. The encapsulation function corresponding to the manual business category is used to implement the module requirements for interacting with the user, and the encapsulation function corresponding to the automatic business category is used to implement the module requirements for automatic processing. The first module requirement is a specific requirement that the module to be generated needs to meet. The embodiment of the present application does not limit the specific requirements that the module to be generated needs to meet. The requirements that the module to be generated needs to meet may be functional requirements, performance requirements, interface requirements, etc., wherein the functional requirement is a specific function or task that the module must perform, which is used to characterize the processing process of the module and the process of interacting with users or other modules. Taking the online payment module as an example, the functional requirement of the online payment module may be at least one of the functional requirements of supporting multiple payment methods, providing payment confirmation and notification functions, and ensuring the security of the payment process; the performance requirement is a specific performance indicator that the module must meet while meeting the functional requirements, such as response time, throughput, resource utilization, etc. Taking the search module as an example, the performance requirement of the search module may be at least one of the performance requirements of search result return time not exceeding 1 second and processing 1000 search requests per second; the interface requirement is the communication protocol and data format requirements that the module must comply with when interacting with other modules. Taking the payment module as an example, the interface requirement of the payment module may include at least one of the interface requirements of supporting Hypertext Transfer Protocol Secure (HTTPS) for secure communication and exchanging data in JSON format. The first existing module is a module that has been developed and is available for use. The second existing module is an existing module selected from the first existing module according to the requirements of the module to be generated, and is used to implement the functions of the module that meets the requirements. Taking the requirements of the module to be generated (such as the requirement to update inventory records for prop A) as an example, the update inventory record module for prop B is selected as the second existing module from the first existing modules (such as the inventory level checking module, the update inventory record module for prop B, and the inventory report generation module), so as to determine the module that meets the requirements of the first module based on the second existing module.

[0070] For example, based on the first module requirement of the module to be generated (such as the requirement to update inventory records for prop A), a second existing module (such as an update inventory record module for prop B) is filtered out from the first existing modules (such as a module for checking inventory levels, a module for updating inventory records for prop B, and a module for generating inventory reports).

[0071] In some embodiments, see Figure 3B , Figure 3B is a second flow chart of the code encapsulation method provided in the embodiment of the present application, for Figure 3A In step 101, based on the first module requirement, the second existing module is determined from the first existing module, which can be done by Figure 3B Steps 1011A to 1012A are implemented, as described in detail below.

[0072] In step 1011A, a first business scenario to which the first module requirement belongs is determined.

[0073] Here, the business scenario (such as the first business scenario) is the specific situation or environment faced by the module in actual use. The business scenario includes a business name and at least one module, wherein the business name is used to characterize the specific scenario in which the business is located. Taking the business scenario with the business name "online reading business" as an example, it can be determined that the business scenario is an online reading scenario, which is used to characterize the scenario of online reading through network communication.

[0074] Among them, each module requirement (such as the first module requirement) is associated with one or more business scenarios to ensure that the requirements match the actual business activities. Taking the first module requirement (such as the requirement to generate user orders) as an example, the business scenario corresponding to the first module requirement is the user order processing scenario. The user order processing scenario includes multiple modules, such as an order receiving module, a system verification product inventory module, an order confirmation generation module, a payment processing module, etc. Taking the first module requirement (such as the requirement to update inventory records) as an example, the business scenario corresponding to the first module requirement is the inventory management scenario. The inventory management scenario includes multiple modules, such as a module for checking inventory levels, a module for updating inventory records, a module for generating inventory reports, etc.

[0075] In some embodiments, the above-mentioned "determining the first business scenario to which the first module requirement belongs" can be achieved in the following manner: determine multiple third business scenarios, perform the following processing for each third business scenario respectively, fuse the module requirements of multiple modules of the third business scenario, and obtain the fused module requirements. When the similarity between the fused module requirements and the first module requirements is greater than the similarity threshold, determine the third business scenario as the first business scenario to which the first module requirement belongs.

[0076] Continuing from the above embodiment, the above “integrating the module requirements of multiple modules of the third business scenario to obtain the integrated module requirements” can be achieved in the following way: splicing the module requirements corresponding to each module of the third business scenario to obtain the integrated module requirements.

[0077] For example, the module requirements corresponding to each module of the third business scenario (such as the user order processing scenario) are spliced ​​together (such as the module requirement of the order receiving module of the user order processing scenario is "receive order", and the module requirement of the order confirmation generating module of the user order processing scenario is "generate order for user confirmation") to obtain the fused module requirements (such as "receive order, generate order for user confirmation").

[0078] Continuing from the above embodiment, before the above "determining the third business scenario as the first business scenario to which the first module requirement belongs", the similarity between the fusion module requirement and the first module requirement is determined in the following manner: determining the edit distance (such as 2) between the first module requirement (such as "input") and the fusion module requirement (such as "manual input"); determining the maximum length (such as 4) between the length of the first module requirement (such as 2) and the length of the fusion module requirement (such as 4); determining the ratio of the difference between the maximum length and the edit distance (such as 2) to the maximum length (such as 0.5) as the similarity between the first module requirement and the fusion module requirement.

[0079] Among them, the edit distance is used to characterize the number of single-character edits (insertion, deletion or replacement) required to transform the first module requirement into the fusion module requirement. The number of single-character edits is the minimum number of edits required to transform the first module requirement into the fusion module requirement. Taking the edit distance between the first module requirement (such as "kitten") and the fusion module requirement (such as "sitting") as an example, in this process, a total of 2 replacements and 1 insertion are performed. The first replacement is to replace the "k" in "kitten" with "s" to obtain "sitten"; the second replacement is to replace the "e" in "sitten" with "i" to obtain "sittin"; the insertion is to insert a "g" at the end of "sittin" to obtain "sitting", so the edit distance between the first module requirement and the fusion module requirement is 3.

[0080] Continuing from the above embodiment, the above-mentioned "determining the similarity between the first module requirements and the fusion module requirements" can also be achieved in the following way: encode the first module requirements (such as "input") to obtain a first coding feature (such as [0.14, 0.13, -0.06]); encode the fusion module requirements (such as "manual input") to obtain a second coding feature (such as [0.14, 0.13, -0.06, 0.15, 0.03, 0.06]); determine the similarity between the first coding feature and the second coding feature (such as 0.85) as the similarity between the first module requirements and the fusion module requirements.

[0081] It should be noted that the embodiment of the present application does not limit the similarity, and the similarity can be the cosine similarity, Euclidean distance, etc. between the first coding feature and the second coding feature.

[0082] In step 1012A, for each first existing module, the second business scenario to which the first existing module belongs is determined, and when the similarity between the first business scenario and the second business scenario is greater than a third similarity threshold, the first existing module is determined as the second existing module.

[0083] It should be noted that the business scenario includes a first business scenario and a second business scenario. The first business scenario is the specific situation or environment faced by the module to be generated in actual use, and the second business scenario is the specific situation or environment faced by the second existing module in actual use.

[0084] In some embodiments, the above-mentioned "determining the second business scenario to which the first existing module belongs" can be implemented in the following way: query the third mapping table based on the first existing module, and determine the business scenario corresponding to the first existing module as the second business scenario, wherein the third mapping table includes the correspondence between different existing models and different business scenarios. In addition, the embodiment of the present application does not limit the correspondence between different existing models and different business scenarios. The correspondence can be that multiple existing models correspond to one business scenario, or that each existing model corresponds to its own business scenario.

[0085] It should be noted that the third mapping table is a data structure used to store the correspondence between existing models and business scenarios. The embodiment of the present application does not limit the third mapping table. The data structure of the third mapping table is similar to the data structure of the first mapping table and will not be repeated here.

[0086] Continuing from the above embodiment, before the above “determining the first existing module as the second existing module”, the step of determining the similarity between the first business scenario and the second business scenario is similar to the step of determining the similarity between the fusion module requirement and the first module requirement, and will not be repeated here.

[0087] For example, for each first existing module, when the similarity (such as 0.85) between the first business scenario (such as the user order processing scenario for application A) and the second business scenario (such as the user order processing scenario for application B) is greater than the third similarity threshold (such as 0.8), the first existing module (such as the business scenario of the first existing module A is the user order processing scenario for application B) is determined as the second existing module (such as the first existing module A).

[0088] Continuing with the above embodiment, after the above "determining the second business scenario to which the first existing module belongs", the second existing module can also be determined in the following manner: when the similarity between the first business scenario and the second business scenario is greater than a third similarity threshold, the first existing module is determined as the third existing module, and based on the requirements of the first module, the second existing module is determined from multiple third existing modules.

[0089] Here, the above step of "determining a second existing module from a plurality of third existing modules" is similar to the above step of "determining a second existing module from a first existing module based on the requirements of the first module", see steps 1011B-1012B for details.

[0090] For example, based on the requirements of the first module (such as the requirement to update inventory records for prop A), a second existing module (such as an update inventory record module for prop B) is screened out from multiple third existing modules (such as a module for checking inventory levels in an inventory management scenario, a module for updating inventory records for prop B, and a module for generating inventory reports).

[0091] In some embodiments, see Figure 3C , Figure 3C is a third flow chart of the code encapsulation method provided in the embodiment of the present application. For the step of "determining the second existing module from the first existing module based on the first module requirement", it can be performed by Figure 3C Steps 1011B to 1012B are implemented as described in detail below.

[0092] In step 1011B, a first cluster to which the first module requirement belongs is determined from the clusters.

[0093] Each cluster includes at least one existing module.

[0094] For example, a first cluster (such as cluster A) to which the first module requirement belongs is selected from multiple clusters (such as cluster A and cluster B).

[0095] In some embodiments, before step 1011B, the following steps are performed: clustering the first existing modules to obtain module categories of the first existing modules; and determining a set of first existing modules belonging to the same module category as a cluster.

[0096] Here, clustering is a method of grouping data (such as the first existing module), and the data in the group has similar characteristics. The embodiment of the present application does not limit the clustering method, and the clustering method can be K-means clustering, hierarchical clustering, etc. The module category is the common characteristics or attributes of the first existing modules in the set. The embodiment of the present application does not limit the module category of the first existing module. The module category of the first existing module includes at least one of the functional module category, compliance module category, and performance module category, wherein the functional module category is used to characterize the specific functions that the module must perform, the compliance module category is used to characterize the laws, standards or industry regulations that the module must comply with, and the performance module category is used to characterize the response time, processing power and resource consumption of the module. The set contains any number of first existing modules, and the first existing modules in the set are unique, and the same first existing modules will not appear.

[0097] For example, clustering is performed on the first existing module to obtain the module category of the first existing module (such as the module category of the first existing module A is the functional module category, the module category of the first existing module B is the functional module category, and the module category of the first existing module C is the performance module category); a set of first existing modules (such as existing module A and existing module B) belonging to the same module category (such as the functional module category) (such as [first existing module A, first existing module B]) is determined as a cluster.

[0098] In some embodiments, step 1011B can be implemented in the following manner: for each cluster, the module requirements corresponding to the first existing module included in the cluster are integrated to obtain the module requirements corresponding to the cluster; when the similarity between the first module requirements and the module requirements corresponding to the cluster is greater than a fourth similarity threshold, the cluster is determined to be the first cluster.

[0099] Here, each cluster includes at least one first existing module, and the first existing modules in the cluster have the same category.

[0100] In some embodiments, the above-mentioned "merging the module requirements corresponding to the first existing modules included in the cluster to obtain the module requirements corresponding to the cluster" can be achieved by the following method: splicing the module requirements corresponding to each first existing module included in the cluster to obtain the module requirements corresponding to the cluster.

[0101] For example, the module requirements corresponding to each first existing module included in the cluster (the module requirement of the order receiving module is "receive order", and the module requirement of the order confirmation generating module is "generate order for user confirmation") are spliced ​​to obtain the module requirements corresponding to the cluster (such as "receive order, generate order for user confirmation").

[0102] Following the above embodiment, before “determining the cluster as the first cluster”, the step of determining the similarity between the first module requirement and the module requirement corresponding to the cluster is similar to the step of determining the similarity between the fusion module requirement and the first module requirement, which will not be repeated here.

[0103] For example, when the similarity (such as 0.85) between the first module requirement (such as the requirement to update inventory records for prop A) and the module requirement corresponding to the cluster (such as the requirement to update inventory records for prop B) is greater than the fourth similarity threshold (such as 0.8), the cluster is determined to be the first cluster.

[0104] Through the embodiment of the present application, the first existing modules are clustered so as to determine the second existing module from the first existing modules included in the first cluster to which the first module requirement belongs, thereby reducing the computational complexity of code packaging.

[0105] In step 1012B, a second existing module is determined from the first existing modules included in the first cluster.

[0106] Here, step 1012B may be implemented in the following manner: performing the following processing respectively on the multiple first existing modules included in the first cluster, and determining the first existing module as the second existing module when the similarity between the module requirement of the first existing module and the first module requirement is greater than a similarity threshold.

[0107] It should be noted that, before the above-mentioned "determining the first existing module as the second existing module", the step of determining the similarity between the module requirements of the first existing module and the requirements of the first module is similar to the step of determining the similarity between the fusion module requirements and the requirements of the first module, and will not be repeated here.

[0108] For example, when the similarity between the module requirement of the first existing module (the order confirmation module for prop B) (such as generating a user order for prop B) and the first module requirement (such as generating a user order for prop B) is greater than a similarity threshold, the first existing module is determined as the second existing module.

[0109] In some embodiments, see Figure 3D , Figure 3D is a fourth flow chart of the code packaging method provided in the embodiment of the present application, Figure 3A After determining the second existing module from the first existing module based on the first module requirement in step 101, execute Figure 3D Steps 201 to 202 are described in detail below.

[0110] In step 201, when the similarity between the first module requirement and the second module requirement of the second existing module is greater than or equal to a second similarity threshold, the second existing module is determined as a module that meets the first module requirement.

[0111] Here, the second module requirement of the second existing module is a specific requirement that the second existing module needs to meet.

[0112] In some embodiments, the step of determining the similarity between the first module requirement and the second module requirement of the second existing module is similar to the step of determining the similarity between the fusion module requirement and the first module requirement, and is not repeated here.

[0113] For example, when the similarity (such as 1) between a first module requirement (such as a requirement to update inventory records for prop A) and a second module requirement (such as a requirement to update inventory records for prop A) of a second existing module (such as an update inventory record module for prop A) is greater than or equal to a second similarity threshold (such as 1), the second existing module is determined as a module that meets the first module requirement.

[0114] In step 202, when the similarity between the first module requirement and the second module requirement of the second existing module is less than or equal to a first similarity threshold, a module satisfying the first module requirement is constructed based on the first module requirement.

[0115] For example, when the similarity (e.g., 0.25) between a first module requirement (e.g., a requirement to update inventory records for item A) and a second module requirement of a second existing module (e.g., a requirement to update order records for item B) is less than or equal to a first similarity threshold (e.g., 0.3), a module that meets the first module requirement is constructed based on the first module requirement.

[0116] In some embodiments, "based on the first module requirement, constructing a module that meets the first module requirement" in step 202 can be implemented in the following way: based on the first module requirement, determine the category of the module to be generated; based on the category of the module to be generated, query the first mapping table, and query the template code corresponding to the category of the module to be generated, wherein the first mapping table includes the correspondence between different categories and different template codes, and the template code includes a fourth code segment for code replacement; based on the first module requirement, construct a fifth code segment; replace the fourth code segment in the template code with the fifth code segment to obtain the code that meets the first module requirement; determine the first packaging method corresponding to the category of the module to be generated, and package the code that meets the first module requirement according to the first packaging method to obtain a module that meets the first module requirement.

[0117] Here, the embodiment of the present application does not limit the correspondence between different categories and different template codes, and the correspondence can be that each category corresponds to its own template code.

[0118] It should be noted that the first mapping table is a data structure used to store the correspondence between categories and template codes. The embodiment of the present application does not limit the first mapping table. The first mapping table can be a data structure implemented as a hash table, an array, etc., which is used to quickly perform the correspondence between categories and template codes. Lookup, insertion and deletion operations, wherein the hash table uses a hash function to calculate the index value, and maps the category of the input module to be generated to the position in the hash table to access the template code.

[0119] For example, the template code A of the conditional branch category is determined, the template code B of the parallel branch category is determined, and the template code (such as template code A) corresponding to the category of the module to be generated (such as the conditional branch category) is queried.

[0120] In some embodiments, the above-mentioned "determining the category of the module to be generated based on the first module requirement" can be achieved in the following way: encoding the first module requirement through a neural network model to obtain the requirement encoding feature, decoding the requirement encoding feature to obtain the category of the module to be generated.

[0121] For example, the first module requirement (such as the requirement to update inventory records for prop A) is encoded to obtain the requirement encoding feature (such as [0.52, 0.13, -0.06, 0.15]), and the requirement encoding feature is decoded to obtain the category of the module to be generated (such as the conditional branch category).

[0122] Continuing from the above embodiment, the above “determining the category of the module to be generated based on the first module requirement” can also be implemented in the following way: extract keywords from the first module requirement to obtain requirement keywords, and determine the category corresponding to the requirement keywords as the category of the module to be generated.

[0123] For example, keyword extraction is performed on the first module requirement (such as the requirement to automatically update inventory records) to obtain requirement keywords (such as automatic), and the category corresponding to the requirement keyword (such as automatic business category) is determined as the category of the module to be generated.

[0124] In some embodiments, the above-mentioned "building the fifth code segment based on the first module requirements" can be implemented in the following way: divide the first module requirements into statements to obtain multiple requirement statements, perform code conversion processing on each requirement statement to obtain the sixth code segment, and combine each sixth code segment to obtain the fifth code segment.

[0125] Continuing from the above embodiment, the above “perform code conversion processing on each requirement statement to obtain the sixth code segment” can be implemented in the following way: perform word segmentation processing on the requirement statement to obtain the requirement word (such as “if”) of the requirement statement (such as “if A is less than 0, execute action B”), determine the encapsulation function corresponding to the requirement word (such as “if (conditional expression) {execute action}”), and rewrite the requirement statement (such as “if A is less than 0, execute B”) based on the encapsulation function to obtain the sixth code segment (such as “if (A is less than 0) {execute action B}”).

[0126] For example, the first module requirements are divided into statements to obtain multiple requirement statements (such as requirement statement 1 is user login, and requirement statement 2 is to display a welcome statement). Code conversion is performed on each requirement statement to obtain a sixth code segment (such as the sixth code segment corresponding to requirement statement 1 is "login", and requirement statement 2 is "printwelcome"). Each sixth code segment is combined to obtain a fifth code segment (such as "login; print welcome").

[0127] In some embodiments, the above-mentioned "building the fifth code segment based on the first module requirements" can also be implemented in the following way: obtaining a code prompt word template, wherein the code prompt word template includes an instruction text for text replacement, replacing the instruction text in the code prompt word template with the first module requirements to obtain a code prompt word, encoding the code prompt word through a neural network model to obtain a code encoding feature, decoding the code encoding feature to obtain the fifth code segment.

[0128] For example, the instruction text (such as "{module requirement}") in the code prompt word template (such as "Please fully understand the module requirement of {module requirement}, and write the code segment according to the understanding") is replaced with the first module requirement (such as displaying a welcome message after the user logs in), and the code prompt words are obtained (such as "Please fully understand the module requirement of displaying a welcome message after the user logs in, and write the code segment according to the understanding"), the code prompt words are encoded through the neural network model, and code encoding features are obtained (such as [0.52, 0.13, -0.06, 0.15]), the code encoding features are decoded, and the fifth code segment is obtained (such as "if (user has logged in) {print "welcome"}".

[0129] In some embodiments, the above step of "determining a first packaging method corresponding to the category of the module to be generated" is similar to step 103 and will not be repeated here.

[0130] It should be noted that the first packaging method corresponding to the type of the module to be generated and the packaging method corresponding to the type of the second existing module may be the same packaging method or different packaging methods.

[0131] In some embodiments, the above step of “packaging the code that meets the requirements of the first module according to the first packaging method to obtain a module that meets the requirements of the first module” is similar to step 104, see step 104 for details.

[0132] Through the embodiments of the present application, different construction methods of the modules are determined according to the similarity between the first module requirements and the second module requirements of the second existing module, thereby improving the efficiency of code packaging.

[0133] Continue to see Figure 3A In step 102, when the similarity between the first module requirement and the second module requirement of the second existing module is greater than the first similarity threshold and less than the second similarity threshold, the code of the second existing module is adjusted to obtain the adjusted code of the second existing module.

[0134] The first similarity threshold is less than the second similarity threshold. The adjusted code of the second existing module includes the unadjusted code in the second existing module and the adjusted code in the second existing module.

[0135] Here, the second existing module includes multiple encapsulation functions, and the code of the second existing module is a combination of the codes of each encapsulation function. The encapsulation code is the code of the encapsulation function. The embodiment of the present application does not limit the encapsulation code. The encapsulation code (such as "def square(x): return x*x") includes an encapsulation function body (such as "def square(x):") and a code segment inside the encapsulation function body (such as "return x*x"), wherein the encapsulation function body encapsulates a group of statements that perform specific tasks into a function in a specific form, and the code segment inside the encapsulation function body is used to execute specific tasks in the function body.

[0136] For example, when the similarity (e.g., 0.75) between a first module requirement (e.g., the requirement to update inventory records for item A) and a second module requirement (e.g., the requirement to update inventory records for item B) of a second existing module (e.g., an inventory record update module for item B) is greater than a first similarity threshold (e.g., 0.3) and less than a second similarity threshold (e.g., 0.85), the code of the second existing module (e.g., "def square(x): return x*x") is adjusted to obtain adjusted code of the second existing module (e.g., "defcubic(x): return x*x*x").

[0137] In some embodiments, see Figure 3E , Figure 3E is a fifth flow chart of the code encapsulation method provided in an embodiment of the present application. The code of the second existing module is adjusted in step 102 shown in FIG. 3 to obtain the adjusted code of the second existing module. Figure 3E Steps 1021 to 1022 are implemented as described in detail below.

[0138] In step 1021, the code of the second existing module is divided to obtain a first code segment, and a second code segment is determined from the first code segment.

[0139] Here, the second existing module includes multiple encapsulation functions, and the division process is to divide the first code according to the function identifier (such as "def") of the encapsulation function, and determine the code of the encapsulation function as the first code segment.

[0140] In some embodiments, the above-mentioned "dividing the code of the second existing module to obtain the first code segment" can be implemented in the following way: based on the function identifier, dividing the code of the second existing module to obtain the first code segment.

[0141] For example, based on the function identifier (such as "def"), the code of the second existing module (such as "defsquare(x): return x*x; def cubic(x): return x*x*x") is divided to obtain the first code segment (such as "defsquare(x): return x*x" and "def cubic(x): return x*x*x").

[0142] Continuing from the above embodiment, the first code segment includes an encapsulated function body and a code segment inside the encapsulated function body, and the above "determining the second code segment from the first code segment" can be implemented in the following way: determining the code segment inside the encapsulated function body in the first code segment as the second code segment.

[0143] For example, the code segment (such as "x*x") inside the encapsulated function body in the first code segment (such as "defsquare(x): x*x") is determined as the second code segment.

[0144] In step 1022, based on the first module requirement, a third code segment is determined, and the second code segment in the code of the second existing module is replaced with the third code segment to obtain an adjusted code of the second existing module.

[0145] Here, determining the third code segment based on the first module requirement in step 1022 can be implemented in the following manner: constructing the third code segment based on the first module requirement.

[0146] It should be noted that the above-mentioned "building a third code segment based on the first module requirements" is similar to the step of "building a fifth code segment based on the first module requirements" in step 202, and will not be repeated here.

[0147] For example, the second code segment (such as "A=10") in the code of the second existing module (such as "A=10; B=A") is replaced with the third code segment (such as "A=20") to obtain the adjusted code of the second existing module (such as "A=20; B=A").

[0148] Continue to see Figure 3A In step 103, a packaging method corresponding to the category of the second existing module is determined.

[0149] Here, the embodiment of the present application does not limit the category of the second existing module. The category of the second existing module can be a conditional branch category, a parallel branch category, a manual business category, and an automatic business category, etc. The embodiment of the present application does not limit the encapsulation method. The encapsulation method can be a combination of multiple encapsulation functions, and each category corresponds to a different encapsulation function.

[0150] In some embodiments, see Figure 3F , Figure 3F is a sixth flow chart of the code encapsulation method provided in the embodiment of the present application, for Figure 3A Step 103 shown can be performed by Figure 3F Steps 1031 to 1032 are implemented as described in detail below.

[0151] In step 1031, the second mapping table is queried based on the category of the second existing module to find a function set corresponding to the category.

[0152] The second mapping table includes corresponding relationships between different categories and different function sets, and each function set includes at least one encapsulation function.

[0153] Here, a function set is a set of encapsulated functions. The number of encapsulated functions in the function set can be one or more. An encapsulated function is a code segment (usually a code for performing a specific task) packaged in a function for easy reuse and maintenance. The embodiments of the present application do not limit the encapsulated function. The specific structure of the encapsulated function may include a function name, function parameters, and a code segment. The function name is used to characterize the specific task that the function needs to complete, and the function parameters are used to characterize the input parameters that the function needs to receive, so as to facilitate data processing of the input parameters to obtain the corresponding output results. The code segment is the code written inside the function to execute the task, which is used to characterize the specific process of task execution.

[0154] It should be noted that the second mapping table is a data structure used to store the correspondence between different categories and different function sets. The embodiment of the present application does not limit the second mapping table. The data structure of the second mapping table is similar to the data structure of the first mapping table and will not be repeated here.

[0155] In step 1032, based on the encapsulation functions included in the function set, an encapsulation method corresponding to the category of the second existing module is determined.

[0156] In some embodiments, when the number of encapsulation functions (such as output function "printA") included in the function set is a preset number (such as 1), the encapsulation function (such as output function) included in the function set is determined as an encapsulation method.

[0157] Continuing from the above embodiment, when the number of encapsulation functions (such as exception handling functions, output functions) included in the function set is greater than a preset number (such as 1), the encapsulation functions (such as exception handling functions, output functions) included in the combined function set are obtained to obtain an encapsulation method (such as [exception handling function, output function]).

[0158] Continue to see Figure 3A In step 104, the adjusted code of the second existing module is packaged according to the packaging method to obtain a module that meets the requirements of the first module.

[0159] Here, the encapsulation method is a combination of multiple encapsulation functions. The embodiment of the present application does not limit the encapsulation method. The encapsulation method can be a combination of encapsulation functions through a class. The encapsulation method includes an initial function, which is used to perform the class initialization process. Each encapsulation function includes an encapsulation function body and the code inside the encapsulation function body, wherein the encapsulation function body encapsulates a group of statements that perform specific tasks into a function in a specific form, and the code inside the encapsulation function body is used to execute specific tasks in the function body.

[0160] In some embodiments, step 104 can be implemented by: replacing the code inside the encapsulated function body with the adjusted code of the second existing module to obtain the function to be encapsulated; combining the initial function and the function to be encapsulated to obtain a module that meets the requirements of the first module.

[0161] For example, the code (such as "*") inside the encapsulation function body in the encapsulation method (such as "defmethod: {*}") is replaced with the adjusted code of the second existing module (such as "return x*x*x") to obtain the function to be encapsulated (such as "defmethod: {return x*x*x}"), and the initial function (such as "definit: {paSS}") and the function to be encapsulated are combined to obtain a module that meets the requirements of the first module (such as "definit: {paSS}; defmethod: {return x*x*x}").

[0162] Through the embodiment of the present application, the code of the adjusted second existing module is encapsulated, which can improve the module's closedness and module reuse rate. At the same time, by comparing the similarities between different module requirements, the code is adjusted after the similarity conditions are met, thereby avoiding the process of fully building the code according to business requirements and improving the efficiency of code encapsulation.

[0163] Below, an exemplary application of the code encapsulation method provided in an embodiment of the present application in an actual application scenario will be described.

[0164] In the related technology, business sub-behaviors (i.e., functions in modules) are all code snippets at the code implementation layer, with a low probability of reuse, and existing business codes are often modified. They have poor closure, fuzzy boundaries between different business codes, high coupling, and poor cohesion, which increases the cost of system maintenance.

[0165] In order to solve the above problems, an embodiment of the present application proposes a code encapsulation method, which improves the reusability and closedness of the module by encapsulating the code.

[0166] In the early stage of business system construction, the code encapsulation method provided in the embodiment of the present application is based on the historical business encapsulation interface and the orchestration business process. The orchestration of the business process is all implemented through hard coding. Figure 4 , Figure 4 is a code encapsulation flow chart provided in an embodiment of the present application, Figure 4 It includes multiple stages for code encapsulation in the embodiment of the present application, such as the first stage 401, the second stage 402 and other stages. The multiple stages of code encapsulation provided by the embodiment of the present application are explained below.

[0167] The first stage, 401, is the initial stage of the business.

[0168] Here, in the initial stage of the business, there is a business scenario 1, including business sub-behavior A1-1 and business sub-behavior A1-20, and the business process is to execute business sub-behavior A1-1 first and then execute business sub-behavior A1-21.

[0169] The business is implemented through code logic S1, that is, business sub-behavior A1-1 is implemented through business sub-behavior code B1-1, business sub-behavior A1-21 is implemented through business sub-behavior code B1-21, and the behavior jump from business sub-behavior A1-1 to business sub-behavior A1-21 is implemented by calling business sub-behavior code B1-21 through business sub-behavior code B1-1.

[0170] As the business develops, new businesses are added, and the original functions do not meet the new business scenario requirements (i.e., the first module requirements). At this time, the second stage 402 is entered. By modifying the original code in the first stage 401, the modified code can support the new business. The second stage 402 is explained below.

[0171] The second stage 402 is the development stage of the business.

[0172] Here, the second stage 402 adds a new business scenario 2 based on the existing business scenario 1, wherein business scenario 1 includes business sub-behavior A1-1 and business sub-behavior A1-21, and the business process is to first execute business sub-behavior A1-1 and then execute business sub-behavior A1-21; business scenario 2 includes business sub-behaviors A1-1, A1-22 and A1-3, and the business process is to first execute business sub-behavior A1-1, then execute business sub-behavior A1-22, and finally execute business sub-behavior A1-3.

[0173] like Figure 4 As shown, the business sub-behavior A1-1 needs to use a fixed business sub-behavior code B1-1 in both scenarios, so the business sub-behavior A1-1 remains unchanged. After the business sub-behavior A1-1 is executed, different business functions need to be executed according to the scenario to which the business belongs, and a new business scenario judgment code C1-1 is added. The business scenario judgment code C1-1 is used to judge whether the scenario of the business processing is scenario 1 or scenario 2. When the business scenario judgment code C1-1 outputs scenario 1, the business sub-behavior code B1-21 (i.e., the code of the second existing module) is executed. At this time, the business scenario 1 is executed. The execution process of the business in the business scenario 1 is to first execute the business sub-behavior code B1-1, then execute the business scenario judgment code C1-1, and finally execute the business sub-behavior code B1-21. When the business scenario judgment code C1-1 outputs scenario 2, since the business sub-behavior A1-22 in the business scenario 2 belongs to a new business function, a new business sub-behavior code B1-22 (i.e., the adjusted code of the second existing module) is added to execute the business sub-behavior A1-22.

[0174] In addition, the business sub-behavior A1-3 in business scenario 2 is also a new business function, and a new business sub-behavior code B1-3 is also required to execute business sub-behavior A1-3. At this time, business scenario 2 is executed, and the execution process of the business in business scenario 2 is to first execute the business sub-behavior code B1-1, then execute the business scenario judgment code C1-1, then execute the business sub-behavior code B1-22, and finally execute the business sub-behavior code B1-3.

[0175] The module includes multiple business sub-behaviors and the behavior interface of the model, see Figure 5 , Figure 5 is a schematic diagram of a behavior interface provided by an embodiment of the present application, such as Figure 5 As shown, the behavior interface 501 of the module provided in the embodiment of the present application includes a top-level interface 502 and subordinate interfaces of different types, which are used to distinguish modules with different behavior characteristics, implement different interfaces according to business characteristics and complete specified behavior logic, for example, a conditional branch type module interface 5031, which is used to process business functions with conditional branches, a parallel conditional branch type module interface 5032, which is used to process business functions with parallel conditional branches, a manual business type module interface 5041, which is used to process business functions with manual participation, and an automatic business type module interface 5042, which is used to process business functions that do not require manual participation.

[0176] The main behaviors involved in the module's behavioral interface include exception handling behavior (such as "onException()"), skip behavior (such as "skip()"), pre-processing behavior (such as "doBefore()"), legality verification behavior (such as "validateStep()"), manual processing behavior (such as "doExe()"), automatic processing behavior (such as "autoExe()"), and conditional branch processing behavior (such as "doBranch()"). Among them, the exception handling behavior is used to execute this behavior when the execution of various behaviors of the module fails, the jump behavior is used to determine whether to skip all behaviors of this module and directly enter the subsequent logic, the pre-processing behavior is used to execute the previous pre-processing matters of this module, the legality verification behavior is used to verify whether the execution of this module is legal, the manual processing behavior (such as "doExe()") is used to characterize the specific execution logic of the manual business module, the automatic processing behavior (such as "autoExe()") is used to characterize the specific execution logic of the automatic business module, and the conditional branch processing behavior is used to characterize the specific execution logic of the conditional branch module.

[0177] The top-level interface 502 is the top-level abstraction of all modules. All modules inherit or implement the top-level interface 502. The top-level interface 502 defines an exception handling behavior, which is used to execute this behavior when the execution of various behaviors of the module fails. Under the top-level interface 502, two super interfaces are derived. The two super interfaces are a branch module interface 503 and a business module interface 504. Among them, the branch module interface 503 is mainly used to handle conditional business or multi-channel parallel business. The branch module interface 503 defines the behavior of obtaining all situations (such as "getAllBranch()"); the business module interface 504 is the main business bearing module, which is used to implement most business behaviors. The business module interface 504 defines a skip behavior. The skip behavior is used to determine whether the module needs to be skipped. For example, if the user does not select a mortgage item, there is no need to enter the mortgage item information.

[0178] The next layer of module interfaces of the branch module interface 503 and the business module interface 504 is the real business support. All business behaviors complete the business functions by implementing the module interface of this layer. Among them, two supporting module interfaces are defined under the branch module interface 503. The two supporting module interfaces include the conditional branch module interface 5031 and the parallel branch module interface 5032. Among them, the conditional branch module interface 5031 is a branch module of multiple selections. Specifically, there may be multiple situations in the business, but the business will only hit one result in the end. For example, the selection of gender (such as male or female), the selection of age group (such as under 30 years old or 30 years old and under 30 years old), the selection of the region (such as region A or region B), the conditional branch module interface 5031 031 defines the branch judgment behavior. Thus, the actual behavior capabilities of the conditional branch type module include the exception handling behavior of the top-level interface 502, the behavior of obtaining all situations of the upper super module interface, and the branch judgment behavior of this module; the parallel branch type module interface 5032 is different from the conditional branch type module interface 5031 in that the parallel branch type module interface 5032 is a multi-select branch module, which is specifically manifested in that there may be multiple situations for the business, but each business may hit part or all of the results, for example, the user's preference choice (the user likes traveling and reading at the same time), the type of props owned (it can be a virtual prop that increases the defense attribute or the attack attribute at the same time), the route to the destination (it can be at least one of route A, route B or route C), etc. The parallel branch type module interface 5032 defines the parallel branch judgment behavior (such as "doConcurrentBranch()").

[0179] Two supporting module interfaces are also defined under the business module interface 504. The two supporting module interfaces include a manual business module interface 5041 and an automatic business module interface 5042. The manual business module interface 5041 and the automatic business module interface 5042 are described in detail below.

[0180] The manual business module interface 5041 is used in scenarios where business behavior requires manual intervention and ultimately requires manual confirmation.

[0181] Here, the behavior of the manual business module is broken down into the following three stages. Each business behavior can always be divided into a pre-occurrence stage, an occurrence stage, and a post-occurrence stage. Among them, in response to the execution operation of the business behavior, the stage before the time point of receiving the execution operation of the business behavior is determined as the pre-occurrence stage. In response to the end operation of the business behavior, the stage after the time point of receiving the end operation of the business behavior is determined as the post-occurrence stage. The stage between the time point of receiving the execution operation of the business behavior and the time point of receiving the end operation of the business behavior is determined as the occurrence stage. In the pre-occurrence stage, the behavior in the pre-occurrence stage includes pre-processing behavior, which is used to include what needs to be done before the business occurs. The pre-processing behavior can be empty, that is, no pre-processing is performed. For example, when the user enters the verification code, it is necessary to send information in advance, and before the user reads the agreement, it is necessary to obtain the agreement content and convert the agreement content into a specific format (such as a picture); in the occurrence stage, when the user performs business operations, the content display will be involved. The embodiment of the present application does not limit the business operation. The business operation can be input information, display information, display and input information, etc. The occurrence stage defines the echo detail behavior (such as "echoDetail()"), wherein the echo detail behavior is used to process the content and display the processed content to the user's terminal; in the post-occurrence stage, the user receives the clear end operation, which can be a submission operation, an agreement operation, etc., and the business is specifically executed through manual processing behavior, such as the user enters the verification code and submits it to verify whether the submitted verification code is correct, and after the user reads and confirms the agreement, the agreement is electronically signed, etc. At the same time, when the user executes the submission, the legitimacy of the steps is verified through the legitimacy verification behavior to ensure that the user executes the submission in the expected order. For example, the business requires the user to operate business 1, business 2, and business 3 in order. However, if the user operates business 1 and then directly skips business 2 to operate business 3, the legality verification behavior is used to verify whether the operation is legal.

[0182] The automatic business module interface 5042 is used to apply to scenarios where some business behaviors do not require manual operation or participation.

[0183] Here, the automatic business module should be independent or require a longer processing time. For example, it can automatically call the risk control system, automatically match records, call other systems to perform operations, etc. The automatic business module defines automatic processing behaviors to support the business behaviors in the automatic business module.

[0184] Take the risk control business handling as an example for detailed explanation, see Figure 6 , Figure 6 This is a flow chart of the risk control business handling provided in the embodiment of the present application. The process of risk control business handling is described in detail below.

[0185] Given an online business processing flow, the online business processing flow provided by the embodiment of the present application is explained below.

[0186] In step 601, the user enters identity information.

[0187] Here, after receiving the identity information entered by the user, step 602 is executed.

[0188] In step 602, the authorization agreement is signed online.

[0189] Here, it is determined whether the user has signed the authorization agreement. If the user has signed the contract, this step is skipped and step 603 is executed.

[0190] In step 603, the user's age is determined.

[0191] Here, if the user's age is between 25 and 50 years old, risk control initial screening model 1 is used to process the user information. If the user's age is less than 25 years old or greater than 50 years old, risk control initial screening model 2 is used to process the user information.

[0192] In step 604, the user confirms the service processing information.

[0193] Here, the user confirms the business processing information and submits it. After receiving the business processing information submitted by the user, step 605 is executed.

[0194] In step 605, seats are automatically allocated according to the user's address.

[0195] Here, according to the principle of proximity, seats can be allocated nearby based on the user's address and the agent's address.

[0196] In step 606, matters are processed simultaneously.

[0197] Here, three items are processed simultaneously, and step 6061, step 6062, and step 6063 are executed in parallel.

[0198] In step 6061, an offline coordination instruction is sent.

[0199] Here, if the amount of the business is greater than 500,000, an offline coordination instruction is sent to the agent to instruct the agent to help the user handle the business offline. After sending the offline coordination instruction, the business handling is completed.

[0200] In step 6062, user information is supplemented.

[0201] Here, an information supplement instruction is sent to the user. If the user chooses to handle the business in the form of mortgage, the user is required to supplement the relevant information, and the business handling is completed after the user supplements the relevant information.

[0202] In step 6063, the risk control model is used to conduct business operations.

[0203] Here, the risk control model may be a risk control limit model, which is used to calculate the credit limit of the user.

[0204] Among them, user identity information entry 601, online signing of authorization agreement 602, user confirmation of business handling information 604 and user information supplement 604 belong to manual business modules. Taking online agreement signing as an example, the manual business module includes skipping behavior, pre-processing behavior, echoing details behavior, security verification behavior and manual processing behavior. The skipping behavior is used to indicate that if the user has already signed a contract in this application, it will be skipped; the pre-processing behavior is used to fill in the contract content and convert it into a long picture; the echoing details behavior is used to return user information and agreement, convert user information and agreement into pictures, and display the converted pictures; the security verification behavior is used to determine whether the application belongs to the state of pending agreement before submission to prevent illegal cross-border access; the manual processing behavior is used to upload the agreement to the electronic signature platform to complete the electronic signature.

[0205] Using risk control initial screening model 1 to process user information, using risk control initial screening model 2 to process user information, using risk control model to handle business 6063, and automatically allocating seats according to user addresses 605 belong to the automatic business module. The automatic business module includes automatic processing behaviors. Taking the use of risk control initial screening model 1 to process user information as an example, the automatic processing behavior is used to assemble user business application information, identity information, etc. By running risk control initial screening model 1 to process user business application information and identity information, the model screening results are obtained, and the model screening results are judged and saved.

[0206] Determining the user's age 603 belongs to a conditional branching module. The conditional branching module includes obtaining all situation behaviors and conditional branching processing behaviors. The obtaining all situation behaviors are used to return all possibilities. Case 1 is that the user's age is between 25 and 50 years old, and case 2 is that the user's age is less than 25 years old or greater than 50 years old. The conditional branching processing behavior is used to characterize which range the user belongs to based on his actual age and return 1 or 2. For example, if the user is 30 years old, 1 is returned, and so on.

[0207] Matters that are processed simultaneously belong to the parallel branch module. The parallel branch module includes obtaining all situation behaviors and parallel branch judgment behaviors. First, obtaining all situation behaviors is used to return all possibilities. Situation 1 is that the amount of the business is greater than 500,000, situation 2 is if the user chooses to handle the business in the form of mortgage, and situation 3 is to calculate the user's credit limit. The subsequent parallel branch judgment behavior is used to calculate the possible hit conditions. For example, assuming that the user applies for an amount of 1 million and does not choose asset mortgage, the parallel branch module will return 1 and 3, and so on.

[0208] Take the business evolution process as an example for detailed description, see Figure 7 , Figure 7 is a business evolution flow chart provided in an embodiment of the present application, Figure 7 The embodiment of the present application includes multiple stages for code encapsulation, such as the initial stage of business 701, the business development stage 702, and multiple stages. The following is an explanation of the multiple stages of business evolution provided by the embodiment of the present application.

[0209] In the initial business stage 701, it is assumed that there is a business scenario 1, including business sub-behavior A1-1 and business sub-behavior A1-21, and the business process is to execute business sub-behavior A1-1 first and then execute business sub-behavior A1-21, among which business sub-behavior A1-1 is a business link with manual participation, and business sub-behavior A1-21 is an automatically executed business link.

[0210] According to the business sub-behavior A1-1, the business module D1-1 (i.e., the second existing module) provided in the embodiment of the present application belongs to the manual business module (i.e., the category of the second existing module), implements the interface (such as the manual business module interface, Manual Flow Handler Interface), and sequentially implements the six methods of skip(), doBefore(), echoDetail(), validateStep(), doExe(), and OnException() logically, wherein the specific method content in the method varies according to the actual business. At the same time, the attribute codes and names of the two modules are assigned. Finally, the business module D1-1 provides a standard access method (i.e., the above six behaviors and two attributes) to the outside. At this time, the business module D1-1 completes the complete logical encapsulation and implementation of the business sub-behavior A1-1.

[0211] According to the business sub-behavior A1-2, write and refine the business module D1-21. The difference from the business module D1-1 is that the business module D1-21 belongs to the automatic business module, and the implemented interface is (such as the automatic business module interface, Auto FlowHandler Interface), and the implemented methods are skip(), autoExe(), and OnException().

[0212] At this point, the two business modules have been encapsulated, and the user-side business scenario 1 only needs to call business module D1-1 and business module D1-21 respectively to complete the business process. The following is a detailed description of the business call process for business scenario 1. First, call the first thread to run business module D1-1, and then call the second thread to run business module D1-21.

[0213] In the business development stage 702, the original functions do not meet the requirements of the new business scenarios, and a new business scenario 2 (i.e., the first business scenario) is added. Among them, there is an existing business scenario 1 (i.e., the second business scenario), including business sub-behavior A1-1 and business sub-behavior A1-21. The business process is to execute business sub-behavior A1-1 first and then business sub-behavior A1-21. The newly added business scenario 2 includes business sub-behaviors A1-1, A1-22 and A1-3. The business process is to execute business sub-behavior A1-1 first, then business sub-behavior A1-22, and finally, business sub-behavior A1-3. Among them, business scenario 1 keeps the original logic unchanged, and the business sub-behavior A1-1 in business scenario 2 is consistent with scenario 1, and the business module D1-1 is directly reused.

[0214] In business scenario 1, the business module D1-21 already exists, but the module does not fully meet the business scenario 2, and some logic needs to be adjusted. At this time, the module encapsulation method provided in the embodiment of the present application needs to create a new copy module D1-22 based on the business module D1-21 (that is, the second existing module), and adjust the logic of the copy module D1-22 according to the requirements of scenario 2, see Figure 6 , assuming that the online signing of the authorization agreement 602 in business scenario 1 is not mandatory to read, but business scenario 2 requires mandatory reading, at this time, the module encapsulation method provided in the embodiment of the present application should maintain the closed nature of the program, and a new online signing of the authorization agreement-mandatory module (i.e. Figure 7 Business module D1-22 in the module) (i.e., the module that meets the requirements of the first module).

[0215] Business sub-behavior A1-3 in business scenario 2 is a new business function. Business module D1-3 is written and refined based on the business function. This module belongs to the manual business module.

[0216] At this point, the module encapsulation of business scenario 2 is completed. Business scenario 2 completes the business process by calling business module D1-1, business module D1-22, and business module D1-3 respectively. The process of business calling for business scenario 2 is described in detail below. First, call the first thread to run business module D1-1, then call the second thread to run business module D1-22, and finally call the third thread to run business module D1-3 to complete the entire scenario business.

[0217] In summary, the code encapsulation method provided in the embodiment of the present application can improve the delivery efficiency of business needs and the efficiency of research and development. The modular construction idea greatly reduces the coupling and complexity of the internal logic of the system, and adopts the strong closure principle to greatly reduce the compatible transformation of the historical code logic during function iteration. At the same time, the improvement of module reusability also reduces the duplication of code construction and reduces the conversion cycle and cost from business to system. While meeting the business, design a more suitable modular business flow from the source or reuse existing modules as much as possible, continuously improve the understanding and abstraction ability of the module, and further improve the reusability and delivery efficiency of the module, thereby entering a virtuous circle of module application and writing.

[0218] The following further describes the exemplary structure of the code encapsulation device 555 provided in the embodiment of the present application implemented as a software module. In some embodiments, for example Figure 2 As shown, the software modules stored in the code packaging device 555 of the memory 550 may include:

[0219] The code determination module 5551 is used to determine the first module requirement of the module to be generated, and based on the first module requirement, determine the second existing module from the first existing module; when the similarity between the first module requirement and the second module requirement of the second existing module is greater than the first similarity threshold and less than the second similarity threshold, the code of the second existing module is adjusted to obtain the adjusted code of the second existing module, and the first similarity threshold is less than the second similarity threshold.

[0220] The code packaging module 5552 is used to determine a packaging method corresponding to the category of the second existing module; and to package the adjusted code of the second existing module according to the packaging method to obtain a module that meets the requirements of the first module.

[0221] In some embodiments, the code determination module 5551 is also used to divide the code of the second existing module to obtain a first code segment, and determine the second code segment from the first code segment; based on the requirements of the first module, determine the third code segment, and replace the second code segment in the code of the second existing module with the third code segment to obtain the adjusted code of the second existing module.

[0222] In some embodiments, the code determination module 5551 is also used to determine the second existing module as a module that meets the first module requirements when the similarity between the first module requirements and the second module requirements of the second existing module is greater than or equal to a second similarity threshold; and to construct a module that meets the first module requirements based on the first module requirements when the similarity between the first module requirements and the second module requirements of the second existing module is less than or equal to the first similarity threshold.

[0223] In some embodiments, the code determination module 5551 is also used to determine the category of the module to be generated based on the first module requirement; query the first mapping table based on the category of the module to be generated, and query the template code corresponding to the third category, wherein the first mapping table includes the correspondence between different categories and different template codes, and the template code includes a fourth code segment for code replacement; construct a fifth code segment based on the first module requirement; replace the fourth code segment in the template code with the fifth code segment to obtain code that meets the first module requirement; determine a first encapsulation method corresponding to the category of the module to be generated, and encapsulate the code that meets the first module requirement according to the first encapsulation method to obtain a module that meets the first module requirement.

[0224] In some embodiments, the code determination module 5551 is also used to determine the first business scenario to which the first module requirement belongs; for each first existing module, determine the second business scenario to which the first existing module belongs, and when the similarity between the first business scenario and the second business scenario is greater than a third similarity threshold, determine the first existing module as the second existing module.

[0225] In some embodiments, the code determination module 5551 is further used to determine, from the clusters, a first cluster to which the first module requirement belongs, wherein each cluster includes at least one first existing module; and to determine a second existing module from the first existing modules included in the first cluster.

[0226] In some embodiments, the code determination module 5551 is also used to, for each cluster, fuse the module requirements corresponding to the first existing module included in the cluster to obtain the module requirements corresponding to the cluster; when the similarity between the first module requirements and the module requirements corresponding to the cluster is greater than a fourth similarity threshold, the cluster is determined to be the first cluster.

[0227] In some embodiments, the code determination module 5551 is further used to perform clustering processing on the first existing modules to obtain module categories of the first existing modules; and determine a set of first existing modules belonging to the same module category as a cluster.

[0228] In some embodiments, the code encapsulation module 5552 is also used to query the second mapping table based on the category of the second existing module, and query the function set corresponding to the first category, wherein the second mapping table includes the correspondence between different first categories and different function sets, and each function set includes an encapsulation function; based on the encapsulation function included in the function set, determine the encapsulation method corresponding to the category of the second existing module.

[0229] An embodiment of the present application provides a computer program product, which includes computer executable instructions. The computer executable instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer executable instructions from the computer-readable storage medium, and the processor executes the computer executable instructions, so that the electronic device executes the code encapsulation method described above in the embodiment of the present application.

[0230] The embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions or computer programs are stored. When the computer-executable instructions or computer programs are executed by a processor, the processor will be caused to execute the code encapsulation method provided by the embodiment of the present application, for example, FIG. 3A to FIG. 3F The code encapsulation method is shown.

[0231] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.

[0232] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0233] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).

[0234] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.

[0235] To summarize, based on the first module requirement, the second existing module is determined from the first existing module. When the similarity between the first module requirement and the second module requirement of the second existing module is greater than the first similarity threshold and less than the second similarity threshold, the code of the second existing module is adjusted to obtain the adjusted code of the second existing module, and the adjusted code of the second existing module is encapsulated in accordance with the encapsulation method corresponding to the category of the second existing module to obtain a module that meets the first module requirement. By encapsulating the adjusted code of the second existing module, the encapsulated code no longer needs to be modified, thereby improving the closedness of the module and the reuse rate of the module. At the same time, by comparing the similarity between the module requirements, the code is adjusted after the similarity conditions are met, thereby avoiding the full construction of the code according to the business requirements and improving the efficiency of code encapsulation.

[0236] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A code packaging method, characterized in that: The method comprises: Determine a first module requirement of a module to be generated, and determine a second existing module from the first existing module based on the first module requirement; When the similarity between the first module requirement and the second module requirement of the second existing module is greater than a first similarity threshold and less than a second similarity threshold, adjusting the code of the second existing module to obtain an adjusted code of the second existing module, and the first similarity threshold is less than the second similarity threshold; Determine a packaging method corresponding to the category of the second existing module; The adjusted code of the second existing module is packaged according to the packaging method to obtain the module that meets the requirements of the first module.

2. The method according to claim 1, characterized in that The step of adjusting the code of the second existing module to obtain the adjusted code of the second existing module includes: Divide the code of the second existing module to obtain a first code segment, and determine a second code segment from the first code segment; Based on the first module requirement, a third code segment is determined, and the second code segment in the code of the second existing module is replaced with the third code segment to obtain an adjusted code of the second existing module.

3. The method according to claim 1 or 2, characterized in that: The method further comprises: In a case where the similarity between the first module requirement and the second module requirement of the second existing module is greater than or equal to the second similarity threshold, determining the second existing module as the module that meets the first module requirement; In a case where the similarity between the first module requirement and the second module requirement of the second existing module is less than or equal to the first similarity threshold, the module satisfying the first module requirement is constructed based on the first module requirement.

4. The method according to claim 3, characterized in that The step of constructing the module that meets the first module requirement based on the first module requirement includes: Based on the first module requirement, determining the category of the module to be generated; Based on the category of the module to be generated, a first mapping table is queried to obtain a template code corresponding to the category of the module to be generated, wherein the first mapping table includes a correspondence between different categories and different template codes, and the template code includes a fourth code segment for code replacement; Based on the first module requirement, construct a fifth code segment; Replace the fourth code segment in the template code with the fifth code segment to obtain code that meets the requirements of the first module; A first encapsulation method corresponding to the category of the module to be generated is determined, and the code that meets the requirements of the first module is encapsulated according to the first encapsulation method to obtain the module that meets the requirements of the first module.

5. The method according to claim 1, characterized in that The determining a second existing module from a first existing module based on the first module requirement includes: Determine a first business scenario to which the first module requirement belongs; For each first existing module, a second business scenario to which the first existing module belongs is determined, and when the similarity between the first business scenario and the second business scenario is greater than a third similarity threshold, the first existing module is determined as a second existing module.

6. The method according to claim 1 or 5, characterized in that: The determining a second existing module from the first existing module based on the first module requirement includes: Determine, from the clusters, a first cluster to which the first module requirement belongs, wherein each cluster includes at least one of the first existing modules; The second existing module is determined from the first existing modules included in the first cluster.

7. The method according to claim 6, characterized in that The determining, from the clusters, a first cluster to which the first module requirement belongs includes: For each cluster, the module requirements corresponding to the first existing module included in the cluster are integrated to obtain the module requirements corresponding to the cluster; In a case where the similarity between the first module requirement and the module requirement corresponding to the cluster is greater than a fourth similarity threshold, the cluster is determined to be the first cluster.

8. The method according to claim 6, characterized in that Before determining, from the clusters, the first cluster to which the first module requirement belongs, the method further includes: Performing clustering processing on the first existing module to obtain a module category of the first existing module; A set of first existing modules belonging to the same module category is determined as a cluster.

9. The method according to claim 1, characterized in that: The determining of the encapsulation method corresponding to the category of the second existing module includes: Based on the category of the second existing module, query the second mapping table to find a function set corresponding to the category, wherein the second mapping table includes a correspondence between different categories and different function sets, and each function set includes a package function; Based on the encapsulation functions included in the function set, an encapsulation method corresponding to the category of the second existing module is determined.

10. An electronic device, characterized in that: The electronic device comprises: A memory for storing computer executable instructions; A processor, for implementing the code encapsulation method according to any one of claims 1 to 9 when executing the computer executable instructions or computer programs stored in the memory.

11. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the code encapsulation method according to any one of claims 1 to 9 is implemented.

12. A computer program product comprising computer executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the code encapsulation method according to any one of claims 1 to 9 is implemented.