Code processing method, device, medium and electronic equipment

By extracting common codes and modularizing business logic with reflective calls and basic components, the method addresses code complexity and maintenance challenges, enhancing maintainability and scalability in face payment applications.

CN113220336BActive Publication Date: 2024-12-03TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202010071337.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-01-21
Publication Date
2024-12-03
Estimated Expiration
2040-01-21

AI Technical Summary

Technical Problem

The increasing complexity of program code logic and maintenance difficulties due to interdependence and varied business scenarios in applications, particularly in face payment systems across different devices, hinder scalability and maintainability.

Method used

A code processing method that extracts common codes for the same business functions to establish a common logic layer, decouples business codes into separate modules, and utilizes a reflective call method for inter-module communication, along with a basic component library to enhance reusability and scalability.

Benefits of technology

This approach reduces logical complexity, improves maintainability and scalability, and facilitates easy addition of new business scenarios by isolating and modularizing code structures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113220336B_ABST
    Figure CN113220336B_ABST
Patent Text Reader

Abstract

The present disclosure provides a code processing method, a code processing device, a computer-readable medium, and an electronic device. The method comprises: obtaining at least two groups of business codes corresponding to different business scenarios; determining the common codes corresponding to the same business functions in each group of the business codes; establishing a common logic layer including the common codes; and modifying the common codes in the business codes into calling codes for calling the common logic layer. The technical solution disclosed in the present disclosure can improve the maintainability, reusability, and scalability of business codes, reduce the cost of maintaining existing codes, and improve the efficiency of developing new businesses.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a code processing method, a code processing device, a computer-readable medium, and an electronic device. Background Art

[0002] With the development of computer technology, various intelligent electronic devices have brought great convenience to people's work and life. By installing applications on mobile phones, computers and other electronic devices, users can be provided with corresponding business services. Due to the wide variety of electronic devices, especially with the continuous expansion of business scenarios, the program code of the application has become increasingly large, and the internal interdependence and calling logic of the code have become increasingly complex, resulting in increasing difficulty in maintaining the program code.

[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0004] The purpose of the present disclosure is to provide a code processing method, a code processing device, a computer-readable medium and an electronic device, thereby overcoming technical problems such as complex code logic and difficult maintenance, at least to a certain extent.

[0005] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.

[0006] According to one aspect of an embodiment of the present disclosure, a code processing method is provided, the method comprising:

[0007] Obtain at least two groups of business codes corresponding to different business scenarios;

[0008] Determining the common codes corresponding to the same business functions in each group of the business codes;

[0009] Establishing a common logic layer including the common code;

[0010] The common code in the business code is modified into a calling code for calling the public logic layer.

[0011] According to one aspect of an embodiment of the present disclosure, a code processing device is provided, the device comprising:

[0012] An acquisition unit, configured to acquire at least two groups of service codes corresponding to different service scenarios;

[0013] A determination unit configured to determine a common code corresponding to the same service function in each group of service codes;

[0014] An establishing unit configured to establish a common logic layer including the common code;

[0015] The modification unit is configured to modify the common code in the business code into a calling code for calling the public logic layer.

[0016] In some embodiments of the present disclosure, based on the above technical solution, the acquisition unit includes:

[0017] a code acquisition unit, configured to acquire original program code of an application and determine at least two business scenarios related to the application;

[0018] A code splitting unit, configured to split the original program code to obtain a business code corresponding to each business scenario;

[0019] A business module layer establishing unit, configured to establish a business module layer including at least two business modules, and determine a business correspondence between the business modules and the business scenarios;

[0020] The code saving unit is configured to save the business code into a business module corresponding to the business scenario according to the business correspondence relationship.

[0021] In some embodiments of the present disclosure, based on the above technical solution, the code acquisition unit includes:

[0022] an application determining unit configured to determine at least two application programs corresponding to different program versions;

[0023] The program code acquisition unit is configured to respectively acquire the original program code of each of the application programs.

[0024] In some embodiments of the present disclosure, based on the above technical solution, the code splitting unit includes:

[0025] A first splitting unit is configured to split the original program code into a program startup code for starting the application and a program running code for running the application;

[0026] The second splitting unit is configured to split the program running code into business codes corresponding to each of the business scenarios.

[0027] In some embodiments of the present disclosure, based on the above technical solution, the code processing device further includes:

[0028] An interface implementation unit, configured to establish an interface implementation object for providing a callable interface in each of the business modules;

[0029] An interface proxy unit, configured to establish an interface proxy object corresponding to each of the interface implementation objects in the common logic layer;

[0030] The reflection calling unit is configured so that the interface proxy object calls the interface implementation object through the reflection mechanism to realize the mutual calling between the various business modules.

[0031] In some embodiments of the present disclosure, based on the above technical solution, the reflection calling unit includes:

[0032] A call determination unit, configured to determine a first business module as a caller and a second business module as a callee;

[0033] A call request sending unit, configured to send a call request for the second business module to the common logic layer through the first business module;

[0034] a proxy object determining unit, configured to determine an interface proxy object of the second business module in the common logic layer according to the call request;

[0035] The implementation object calling unit is configured to call the interface implementation object of the second business module through the interface proxy object of the second business module.

[0036] In some embodiments of the present disclosure, based on the above technical solution, the proxy object determination unit includes:

[0037] an identification information obtaining unit, configured to obtain identification information of the second service module from the call request;

[0038] The proxy object searching unit is configured to search the common logic layer for the interface proxy object of the second business module corresponding to the identification information.

[0039] In some embodiments of the present disclosure, based on the above technical solution, the determining unit includes:

[0040] a program business function determination unit, configured to determine at least two business functions related to the application program;

[0041] A function code determination unit, configured to respectively determine a function code in each group of the service codes for implementing the service function;

[0042] The common code determining unit is configured to determine the function codes for implementing the same service function in each group of service codes as common codes.

[0043] In some embodiments of the present disclosure, based on the above technical solution, the establishing unit includes:

[0044] a code service function determination unit, configured to determine a service function associated with the common code;

[0045] A common logic layer establishing unit, configured to establish a common logic layer including at least two function modules, and determine a functional correspondence between the function modules and the business functions;

[0046] The common code storage unit is configured to store the common code in a function module corresponding to the business function according to the function correspondence.

[0047] In some embodiments of the present disclosure, based on the above technical solution, the code processing device further includes:

[0048] A basic function determination unit, configured to determine at least two basic functions related to the application, and determine the business code and the basic code in the common code for implementing the basic functions;

[0049] A basic component layer establishing unit is configured to establish a basic component layer including at least two basic components, and determine a component correspondence between the basic components and the basic functions;

[0050] A basic code storage unit, configured to store the basic code in a basic component corresponding to the basic function according to the component correspondence relationship;

[0051] The basic code modification unit is configured to modify the business code and the basic code in the common code into a calling code for calling the basic component.

[0052] In some embodiments of the present disclosure, based on the above technical solution, the code processing device further includes:

[0053] a function call request sending unit, configured to, when a first basic component corresponding to a first basic function needs to implement a second basic function, send a function call request for the second basic function to the common logic layer by the first basic component;

[0054] The basic unit calling unit is configured to call the second basic component corresponding to the second basic function through the common logic layer according to the function calling request.

[0055] In some embodiments of the present disclosure, based on the above technical solution, the code processing device further includes:

[0056] A new service code acquisition unit is configured to acquire a new service code for a new service scenario;

[0057] The newly added service code modification unit is configured to modify the common code in the newly added service code into a calling code for calling the common logic layer when the newly added service code includes the common code.

[0058] According to one aspect of an embodiment of the present disclosure, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the code processing method in the above technical solution is implemented.

[0059] According to one aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the code processing method in the above technical solution by executing the executable instructions.

[0060] In the technical solution provided by the embodiments of the present disclosure, by extracting common codes that implement the same business functions from each group of business codes to establish a common logic layer, the relative independence of business codes corresponding to different business scenarios can be guaranteed, the logical complexity of the business codes can be reduced, the maintainability, reusability and scalability of the business codes can be improved, the cost of maintaining existing codes can be reduced, and the efficiency of developing new businesses can be improved.

[0061] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0063] Figure 1 A schematic diagram of an exemplary system architecture applying the technical solution of the present disclosure is shown.

[0064] Figure 2 The following is a schematic flowchart of the steps of the code processing method in some embodiments of the present disclosure.

[0065] Figure 3 A flowchart schematically illustrates the steps of obtaining a service code to be processed in some embodiments of the present disclosure.

[0066] Figure 4 The flowchart schematically shows the steps of reflectively calling a business module in some embodiments of the present disclosure.

[0067] Figure 5 The schematic diagram schematically shows the principle of implementing mutual calling of business modules based on the reflection mechanism.

[0068] Figure 6 The flowchart schematically shows the steps of establishing a basic component library in some embodiments of the present disclosure.

[0069] Figure 7 A number of different types of facial payment devices are schematically shown.

[0070] Figure 8 The code system architecture diagram implemented by applying the technical solution of the present disclosure is schematically shown.

[0071] Fig. 9 The structural block diagram of the code processing device in some embodiments of the present disclosure is schematically shown.

[0072] Fig.10 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0073] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be more comprehensive and complete and will fully convey the concept of the example embodiments to those skilled in the art.

[0074] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring the various aspects of the present disclosure.

[0075] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0076] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0077] In the related technologies in this field, developers need to consider various business scenarios when developing applications. Taking face payment applications as an example, with the popularization of face recognition technology, there are more and more types of hardware devices that support face payment, which has derived a variety of usage scenarios covering various industries. For example, the large-screen scene of self-service checkout in shopping malls and supermarkets, the independent checkout scene at the checkout counter of convenience stores, the offline checkout scene of school canteens, subways and buses, and the small program member checkout scene with strong appeal to members, etc. The program codes that implement the business functions of many usage scenarios are integrated into the main module of the same software development kit (SDK) of the face payment terminal, making the business code more and more difficult to maintain. At the same time, it becomes difficult to add new business usage scenarios to the original code architecture, and the scalability of the architecture is getting worse and worse.

[0078] In view of the problems existing in the above related technologies, the technical solution disclosed in the present invention provides a code processing method, a code processing device, a computer-readable medium and an electronic device. Figure 1 A schematic diagram of an exemplary system architecture applying the technical solution of the present disclosure is shown.

[0079] like Figure 1 As shown, the system architecture 100 may include a client 110, a network 120, and a server 130. The client 110 may include various terminal devices such as a smart phone, a tablet computer, a laptop computer, a desktop computer, etc. The server 130 may include various server devices such as a network server, an application server, a database server, etc. The network 120 may be a communication medium of various connection types that can provide a communication link between the client 110 and the server 130, for example, a wired communication link or a wireless communication link.

[0080] According to the implementation requirements, the system architecture in the embodiment of the present disclosure may have any number of clients, networks, and servers. For example, the server 130 may be a server group composed of multiple server devices. In addition, the code processing method and the code processing device in the embodiment of the present disclosure may be applied to the client 110 or the server 130, and the present disclosure does not make any special limitation on this.

[0081] For example, when the code processing method and code processing device in the embodiments of the present disclosure are applied to the server 130, the program code for different business scenarios can be processed by the server device in the server 130, and then the program code can be packaged into applications suitable for different business scenarios, such as mobile phone applications, computer applications, etc., and then the application can be installed on the corresponding client 110 to realize the business service functions of the application in different business scenarios.

[0082] The code processing method, code processing device, computer-readable medium and electronic device provided by the present disclosure are described in detail below in conjunction with specific implementations.

[0083] Figure 2 The following schematically shows a flowchart of the steps of the code processing method in some embodiments of the present disclosure. Figure 2 As shown, the method can mainly include the following steps:

[0084] Step S210: Obtain at least two groups of service codes corresponding to different service scenarios.

[0085] Business scenarios may include the use scenarios of the application on different types of terminal devices, such as mobile phones, computers, etc. In addition, business scenarios may also include the use scenarios of the application in different business environments on the same type of terminal device, such as online and offline use scenarios. The business codes corresponding to different business scenarios have the same parts in code content, and also different parts.

[0086] Step S220: Determine the common codes corresponding to the same business functions in each group of business codes.

[0087] This step can first determine at least two business functions related to the application, such as the loading and display functions of the user interface (UI), the loading and jump functions of the advertising link, and so on. On the basis of determining the business functions, the function codes used to implement each business function in each group of business codes can be determined separately. For example, according to the business functions that can be implemented by a group of business codes, one or more function codes can be extracted from the business code, wherein each function code can be used to implement a business function. Among the many business functions provided by the application to the user, there are some core business functions that need to be provided in different business scenarios, and correspondingly, there are function codes for implementing the same business functions in each group of business codes. Therefore, the function codes for implementing the same business functions in each group of business codes can be determined as common codes. For example, there is a function code a for implementing business function A in both the first group of business codes and the second group of business codes, then function code a is determined as the common code of the first group of business codes and the second group of business codes. For another example, if both the second group of business codes and the third group of business codes contain a function code b for implementing business function B, then function code b can be determined as a common code for the second group of business codes and the third group of business codes.

[0088] Step S230: Establish a common logic layer including common codes.

[0089] One or more sections of shared code can be obtained by step S220. For each section of shared code, the business function related to the shared code can be determined first, that is, the business function that each section of shared code is used to implement. Then a common logic layer including at least two function modules can be established, and the functional correspondence between the function module and the business function can be determined. Finally, the shared code is saved in the function module corresponding to the business function according to the functional correspondence. A function module can be a separate code file or a plurality of interrelated code files, and the common logic layer is a file group composed of these code files. For example, seven sections of shared code are obtained by step S220, wherein each section of shared code corresponds to a business function, then this step can establish a common logic layer including seven function modules, wherein each section of shared code can be saved in the function module corresponding thereto. By establishing a common logic layer, the isolation between the shared code and the original business code can be realized, and the isolation between each section of shared code can be realized by using the function modules in the common logic layer. In this way, the independence of each section of code can be realized, and the convenience of code maintenance can be improved.

[0090] Step S240: Modify the common code in the business code into a calling code for calling the public logic layer.

[0091] The public logic layer can provide a calling interface to the outside world and be relied upon by each group of business codes. When each group of business codes needs to implement a common business function, the calling code can be executed to call the public logic layer through the calling interface. On the basis of the existing business scenarios, when a new business scenario needs to be added, the new business code of the new business scenario can be obtained first, and then it can be determined whether the new business code contains the common code corresponding to the public logic layer. When the new business code includes the common code, the common code in the new business code can be modified to the calling code for calling the public logic layer, so that the new business code corresponding to the new business scenario can also call the public logic layer.

[0092] In the code processing method provided in the embodiment of the present disclosure, by extracting common codes that implement the same business functions from each group of business codes to establish a common logic layer, the relative independence of business codes corresponding to different business scenarios can be guaranteed, the logical complexity of the business code can be reduced, the maintainability and scalability of the business code can be improved, and the convenience of adding new business scenarios based on the existing code can be improved.

[0093] The at least two groups of business codes processed in the embodiment of the present disclosure may be obtained by splitting a group of original program codes. Figure 3 The following schematically shows a flow chart of steps for obtaining a service code to be processed in some embodiments of the present disclosure. Figure 3 As shown, based on the above embodiment, step S210. Obtaining at least two groups of service codes corresponding to different service scenarios may include the following steps:

[0094] Step S310: Obtain the original program code of the application and determine at least two business scenarios related to the application.

[0095] This step can obtain a set of original program codes for an application separately, or it can also obtain multiple sets of original program codes for multiple applications at the same time. For example, this step can first determine at least two applications corresponding to different program versions, and then obtain the original program code of each application separately. Among them, different program versions can be specially designed to adapt to different types of terminals. For example, the same application can design a mobile version program for a mobile terminal, and a computer version program for a computer terminal. According to the different business functions that the application can achieve, at least two business scenarios related to the application can be determined. Taking an application that provides face-swiping payment as an example, this step can determine various business scenarios related to it, such as member face-swiping, offline recognition, real-name authorization, etc.

[0096] Step S320: Split the original program code to obtain the business code corresponding to each business scenario.

[0097] In the original program code to be processed, the business codes of different business scenarios usually have complex dependencies with each other in order to call each other. This step will separate the business codes corresponding to different business scenarios to achieve the decoupling of each business scenario. In some optional implementations, the use process of the application can be divided into two parts: the program startup phase and the program running phase after the program is started. On this basis, this step can first split the original program code into a program startup code for starting the application and a program running code for running the application, and then the program startup code can be saved in the main project of the program code, and the program running code can be further split into business codes corresponding to each business scenario.

[0098] Step S330: Establish a business module layer including at least two business modules, and determine the business correspondence between the business modules and the business scenarios.

[0099] Similar to the establishment method of the common logic layer, this step can establish a business module layer including at least two business modules, and determine the business correspondence between each business module and each business scenario. A business module can be an independent project directory in a code engineering project, which can form a single code file or multiple interrelated code files, and the business module layer is a file group composed of code files corresponding to each business module. For example, six groups of business codes corresponding to six business scenarios are obtained by splitting up in step S320, then this step can establish a business module layer including six business modules, wherein each business module has a one-to-one correspondence with a business scenario, and this correspondence is expressed as a business correspondence.

[0100] Step S340: Save the business code to the business module corresponding to the business scenario according to the business correspondence.

[0101] According to the business correspondence between each business module and each business scenario, this step can save each group of business codes obtained by splitting into business modules corresponding to each business scenario.

[0102] The disclosed embodiment establishes a business module layer composed of business modules, so that each group of business codes corresponding to different business scenarios can be isolated from each other to achieve the independence of each group of business codes. When it is necessary to add new business codes corresponding to new business scenarios, it is sufficient to add new business modules in the business module layer without interfering with the business codes of other business scenarios. When it is necessary to modify a certain group of business codes, it is sufficient to modify only a single business module, and it will not affect the business codes in other business modules. Therefore, the maintainability and scalability of the business code can be greatly improved.

[0103] The business code is decoupled and isolated through the business modules in the business module layer, which also results in the business code in each business module being unable to make direct dependency calls. To solve this problem, the technical solution disclosed in the present invention can adopt a reflective call method. Figure 4 The flowchart of the steps of performing reflective calling on the business module in some embodiments of the present disclosure is schematically shown. Figure 4 As shown, the method for reflectively calling a business module may mainly include the following steps:

[0104] Step S410: Establish an interface implementation object for providing a callable interface in each business module.

[0105] In the public logic layer, we can first establish an interface class Proxy API that can be used by each business module to provide a callable interface. Then, each business module inherits the method of the interface class Proxy API and implements it in specific code to obtain the interface implementation object.

[0106] Step S420: Establish interface proxy objects corresponding to each interface implementation object in the public logic layer.

[0107] A new proxy class Proxy is created in the public logic layer, and the proxy class Proxy inherits the methods of the interface class Proxy API, that is, the interface proxy object corresponding to each interface implementation object is obtained.

[0108] Step S430: The interface proxy object calls the interface implementation object through the reflection mechanism to realize mutual calling between various business modules.

[0109] Figure 5 The schematic diagram shows the principle of implementing mutual calling of business modules based on the reflection mechanism. Figure 5 As shown, a first interface implementation object 511 is established inside the first business module 510, and a second interface implementation object 521 is established inside the second business module 520. A first interface proxy object 531 corresponding to the first interface implementation object 511 and a second interface proxy object 532 corresponding to the second interface implementation object 512 are established in the public logic layer 530.

[0110] When the first business module 510 needs to call the second business module 520, the first business module 510 can be determined as the caller, and the second business module 520 can be determined as the callee. The first business module 510 can send a call request for the second business module 520 to the public logic layer 530. According to the call request, the interface proxy object of the second business module 520 can be determined in the public logic layer 530, that is, the second interface proxy object 532 can be determined.

[0111] The method for determining the second interface proxy object 532 may be to obtain identification information (such as attribute name) of the second business module 520 from the call request, and then search the interface proxy object of the second business module 520 corresponding to the identification information in the public logic layer 530.

[0112] After determining the second interface proxy object 532, the interface implementation object of the second service module 520 can be called through the second interface proxy object 532, that is, the second interface implementation object 521 can be called. In this way, the reflection call of the first service module 510 to the second service module 520 can be completed.

[0113] When the second service module 520 needs to call the first service module 510, the first service module 510 can be determined as the called party, and the second service module 520 can be determined as the caller. The second service module 520 can reflectively call the first service module 510 by executing the same method steps as the above solution.

[0114] In order to further improve the reusability of the code, the present disclosure may further split the business code and the shared code to establish a basic component library. Figure 6 The flowchart of the steps for establishing a basic component library in some embodiments of the present disclosure is schematically shown. Figure 6 As shown, based on the above embodiments, the method for establishing a basic component library includes the following steps:

[0115] Step S610. Determine at least two basic functions related to the application, and determine the business code and the basic code in the common code for implementing the basic functions.

[0116] The business functions of an application are directly user-oriented and are business service functions that users can intuitively feel, such as member face recognition function, real-name authorization function, etc. Such business functions can only be realized with the support of underlying basic functions, such as logging function, cross-process communication function, data reporting function, data download function, etc. The basic code used to implement various basic functions can be determined in both business code and shared code.

[0117] Step S620: Establish a basic component layer including at least two basic components, and determine the component correspondence between the basic components and the basic functions.

[0118] Similar to the establishment of the common logic layer and the business module layer, this step can establish a basic component layer including at least two basic components, and determine the component correspondence between each basic component and each basic function. A basic component can be a single code file or multiple interrelated code files, and the basic component layer is a file group consisting of code files corresponding to each basic component. For example, if step S610 determines twelve groups of basic codes corresponding to twelve basic functions, then this step can correspondingly establish a basic component layer including twelve basic components, wherein each basic component has a one-to-one correspondence with a basic function, and the correspondence is expressed as a component correspondence.

[0119] Step S630. Save the basic code to the basic component corresponding to the basic function according to the component correspondence.

[0120] According to the component correspondence between each basic component and each basic function, this step can save the basic code used to implement the basic function into the basic component corresponding to each basic function.

[0121] Step S640: Modify the business code and the basic code in the common code into a calling code for calling the basic component.

[0122] Each basic component can provide a calling interface to the outside. After the basic code in the business code and the shared code is modified into the calling code for calling the basic component, each business module in the business module layer and each functional module in the public logic layer can directly call each basic component in the basic component layer according to the function implementation needs. Moreover, since each basic component is separated from the business logic of the application, each basic component in the basic component library can be provided to other applications as a common component.

[0123] Each basic component in the basic component layer is also isolated from each other, so when each basic component needs to call each other, it can be realized with the help of the common logic layer. For example, when the first basic component corresponding to the first basic function needs to implement the second basic function, the first basic component sends a function call request for the second basic function to the common logic layer. Then, according to the function call request, the second basic component corresponding to the second basic function is called through the common logic layer.

[0124] The following describes the details of the code processing method provided in the above embodiments of the present disclosure in conjunction with the specific application scenarios of face payment.

[0125] With the development of face recognition technology, face payment function can now be realized on many different types of terminal devices. Figure 7A variety of different types of face payment devices are schematically shown, among which the large-screen self-service cashier device 710 can be used as a self-service cashier counter in a supermarket or shopping mall, and the single-screen cashier device 720 and the dual-screen cashier device 730 can be used at a manual cashier counter to assist manual face payment cashier. Among them, the dual-screen cashier device 730 includes two screens: a "front screen" located on the front of the device and a "rear screen" located on the back of the device. The rear screen can be operated by the cashier to initiate interaction. The front screen can be operated by the cashier object for face recognition and information display. Different versions of applications need to be designed for different types of cashier devices. Using the technical solution disclosed in this disclosure, their application codes can be integrated to form a code system that is easy to maintain and convenient to expand.

[0126] Figure 8 The following schematically shows the code system architecture diagram implemented by applying the technical solution of the present disclosure. Figure 8 As shown, the overall architecture of the system is divided into three layers from top to bottom, namely, a business module layer 810, a public logic layer 820 and a basic component layer 830.

[0127] The business module layer 810 is the top layer of the architecture and is split according to business scenarios. The business modules 811 within the business module layer 810 are decoupled and will not depend on each other. Customized demand development can be done for various business scenarios.

[0128] As the middle layer of the architecture, the public logic layer 820 implements the core business functions reused by each business module 811 through the function module 821, such as 1:1 payment, 1:N payment and other core capabilities. The public logic layer 820 is relied upon by each business module 811 in the business module layer 810.

[0129] The basic component layer 830, as the bottom layer of the architecture, is split into basic components 831 of atomic functional modules. The basic components 831 do not understand business functions and are independent of each other. They can be provided to the outside in the form of basic general components split into atomic functional modules to achieve component reuse.

[0130] The process of using the disclosed technical solution to perform code processing in this application scenario is as follows:

[0131] 1. Split the business module layer:

[0132] (1) According to the usage scenarios of the business, six business modules are established under the project. As shown in the figure, they can specifically include the large screen face recognition module (sdk_module), the front screen face recognition module (lpas_module), the member face recognition module (member_module), the back screen module (backscreen_module), the offline recognition module (offline_module) and the real-name authorization module (auth_module).

[0133] (2) Save the business code belonging to each business usage scenario into their respective library module projects.

[0134] (3) The main project only retains the logic related to application startup loading.

[0135] 2. Split the public logic layer:

[0136] (1) The common parts of each business module are sunk to the public logic layer.

[0137] (2) Modify the code under each business module and modify the part reused by each business module into the calling code that calls the public logic layer.

[0138] (3) After the split is completed, the public logic layer includes functional modules corresponding to the shared code parts such as UI components, 1:1 payment, 1:N payment, advertising, red envelopes, card package membership and settings page.

[0139] 3. Split the basic component layer

[0140] (1) According to the 12 basic functions, 12 library projects are established in the project directory, and the codes of each function are moved to the corresponding projects to form basic components. Specifically, they include log lib (lib-log), mini program lib (lib-miniapp), code scanning lib (lib-qrcode), message bus lib (lib-event), inter-process communication lib (lib-ipc), download lib (lib-download), camera lib (lib-camera), network request lib (lib-network), report lib (lib-report), voice tts lib (lib-tts), positioning lib (lib-location) and upgrade lib (lib-upgrade).

[0141] (2) Remove the dependencies between basic components and move the interdependent calling logic to the common logic layer to keep the basic components independent.

[0142] In the technical solution disclosed in the present invention, by splitting the code of each business scenario into a separate module, the decoupling of each business scenario is achieved, and the maintainability of the code is improved. By componentizing the basic functions and decoupling them from other functional modules, the basic functional modules are independent components, which improves the reusability of the code. By extracting the public logic code and putting it in the public logic layer, the ability of newly added business scenarios to directly use the public interface is achieved, which improves the scalability of the code.

[0143] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0144] The following describes an apparatus embodiment of the present disclosure, which can be used to execute the code processing method in the above-mentioned embodiment of the present disclosure. For details not disclosed in the apparatus embodiment of the present disclosure, please refer to the above-mentioned embodiment of the code processing method of the present disclosure.

[0145] Fig. 9 The structure block diagram of the code processing device in some embodiments of the present disclosure is schematically shown. Fig. 9 As shown, the code processing device 900 may mainly include:

[0146] The acquisition unit 910 is configured to acquire at least two groups of service codes corresponding to different service scenarios;

[0147] A determination unit 920 is configured to determine a common code corresponding to the same service function in each group of service codes;

[0148] The establishing unit 930 is configured to establish a common logic layer including common codes;

[0149] The modifying unit 940 is configured to modify the common code in the business code into a calling code for calling the public logic layer.

[0150] In some embodiments of the present disclosure, based on the above embodiments, the acquisition unit 910 includes:

[0151] A code acquisition unit, configured to acquire original program code of the application and determine at least two business scenarios related to the application;

[0152] A code splitting unit, configured to split the original program code into business codes corresponding to each business scenario;

[0153] A business module layer establishing unit, configured to establish a business module layer including at least two business modules, and determine a business correspondence between the business modules and the business scenarios;

[0154] The code saving unit is configured to save the business code into a business module corresponding to the business scenario according to the business correspondence relationship.

[0155] In some embodiments of the present disclosure, based on the above embodiments, the code acquisition unit includes:

[0156] an application determining unit configured to determine at least two application programs corresponding to different program versions;

[0157] The program code acquisition unit is configured to respectively acquire the original program code of each application program.

[0158] In some embodiments of the present disclosure, based on the above embodiments, the code splitting unit includes:

[0159] A first splitting unit is configured to split the original program code into a program startup code for starting the application and a program running code for running the application;

[0160] The second splitting unit is configured to split the program running code into business codes corresponding to each business scenario.

[0161] In some embodiments of the present disclosure, based on the above embodiments, the code processing device 900 further includes:

[0162] The interface implementation unit is configured to establish an interface implementation object for providing a callable interface in each business module;

[0163] The interface proxy unit is configured to establish an interface proxy object corresponding to each interface implementation object in the common logic layer;

[0164] The reflection calling unit is configured as an interface proxy object to call the interface implementation object through a reflection mechanism to realize mutual calling between various business modules.

[0165] In some embodiments of the present disclosure, based on the above embodiments, the reflection calling unit includes:

[0166] A call determination unit, configured to determine a first business module as a caller and a second business module as a callee;

[0167] A call request sending unit, configured to send a call request for a second business module to the common logic layer through the first business module;

[0168] A proxy object determination unit, configured to determine an interface proxy object of the second business module in the public logic layer according to a call request;

[0169] The implementation object calling unit is configured to call the interface implementation object of the second business module through the interface proxy object of the second business module.

[0170] In some embodiments of the present disclosure, based on the above embodiments, the proxy object determination unit includes:

[0171] An identification information acquisition unit, configured to acquire identification information of the second service module from the call request;

[0172] The proxy object searching unit is configured to search the interface proxy object of the second business module corresponding to the identification information in the public logic layer.

[0173] In some embodiments of the present disclosure, based on the above embodiments, the determining unit 920 includes:

[0174] a program business function determination unit, configured to determine at least two business functions related to the application program;

[0175] A function code determination unit, configured to respectively determine a function code in each group of service codes for implementing a service function;

[0176] The common code determination unit is configured to determine the function codes for implementing the same service function in each group of service codes as common codes.

[0177] In some embodiments of the present disclosure, based on the above embodiments, the establishing unit 930 includes:

[0178] A code service function determination unit configured to determine a service function associated with the common code;

[0179] A common logic layer establishing unit, configured to establish a common logic layer including at least two function modules, and determine a function correspondence between the function modules and the business functions;

[0180] The common code storage unit is configured to store the common code in a function module corresponding to the business function according to the function correspondence relationship.

[0181] In some embodiments of the present disclosure, based on the above embodiments, the code processing device 900 further includes:

[0182] A basic function determination unit, configured to determine at least two basic functions related to the application program, and determine a basic code in the business code and the common code for implementing the basic functions;

[0183] A basic component layer establishing unit is configured to establish a basic component layer including at least two basic components and determine a component correspondence between the basic components and the basic functions;

[0184] A basic code storage unit is configured to store the basic code in a basic component corresponding to the basic function according to the component correspondence relationship;

[0185] The basic code modification unit is configured to modify the basic code in the business code and the common code into a calling code for calling the basic component.

[0186] In some embodiments of the present disclosure, based on the above embodiments, the code processing device 900 further includes:

[0187] a function call request sending unit, configured to, when the first basic component corresponding to the first basic function needs to implement the second basic function, send the function call request for the second basic function to the common logic layer by the first basic component;

[0188] The basic unit calling unit is configured to call the second basic component corresponding to the second basic function through the public logic layer according to the function calling request.

[0189] In some embodiments of the present disclosure, based on the above embodiments, the code processing device 900 further includes:

[0190] A new service code acquisition unit is configured to acquire a new service code for a new service scenario;

[0191] The newly added business code modification unit is configured to modify the common code in the newly added business code into a calling code for calling the public logic layer when the newly added business code includes the common code.

[0192] The specific details of the code processing device provided in each embodiment of the present disclosure have been described in detail in the corresponding method embodiment, and will not be repeated here.

[0193] Fig.10 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure is shown.

[0194] It should be noted that Fig.10 The computer system 1000 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0195] like Fig.10As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1002 or the program loaded from the storage part 1008 to the random access memory (RAM) 1003. Various programs and data required for system operation are also stored in the RAM 1003. The CPU 1001, the ROM 1002 and the RAM 1003 are connected to each other through a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0196] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed so that a computer program read therefrom is installed into the storage section 1008 as needed.

[0197] In particular, according to an embodiment of the present disclosure, the process described in each method flow chart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 1009, and / or installed from a removable medium 1011. When the computer program is executed by a central processing unit (CPU) 1001, various functions defined in the system of the present application are executed.

[0198] It should be noted that the computer-readable medium shown in the embodiment of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0199] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0200] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0201] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0202] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modifications, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.

[0203] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A code processing method, characterized in that: include: Obtaining the original program code of the application, and determining at least two business scenarios related to the application; splitting the original program code to obtain business codes corresponding to each of the business scenarios; establishing a business module layer including at least two business modules, and determining the business correspondence between the business modules and the business scenarios; saving the business code to the business module corresponding to the business scenario according to the business correspondence, where different business scenarios refer to the usage scenarios of the application under different business environments on the same type of terminal device; establishing an interface implementation object for providing a callable interface in each of the business modules; Determine at least two basic functions related to the application, establish a basic component layer including basic components, and determine a component correspondence between the basic components and the basic functions; The basic codes of the basic functions are respectively saved in the basic components corresponding to the basic functions, and the basic codes in the business code are modified into calling codes for calling the basic components; Determining the common codes corresponding to the same business functions in each group of the business codes; Determine the business function related to the common code; establish a common logic layer including at least two function modules, and determine the functional correspondence between the function modules and the business function; save the common code to the function module corresponding to the business function according to the functional correspondence; Establishing interface proxy objects corresponding to each of the interface implementation objects in the common logic layer; Modifying the basic code in the shared code into a calling code for calling the basic component; Modify the common code in the business code into a calling code for calling the common logic layer; Among them, the mutual calling process between each of the business modules includes: determining a first business module as a caller and a second business module as a callee; sending a calling request for the second business module to the common logic layer through the first business module; determining an interface proxy object of the second business module in the common logic layer according to the calling request; and calling an interface implementation object of the second business module through the interface proxy object of the second business module.

2. The code processing method according to claim 1, characterized in that: The obtaining of the original program code of the application program includes: determining at least two application programs corresponding to different program versions; The original program code of each of the applications is obtained respectively.

3. The code processing method according to claim 1, characterized in that: The step of splitting the original program code to obtain a business code corresponding to each business scenario includes: Splitting the original program code into a program startup code for starting the application and a program running code for running the application; The program running code is split into business codes corresponding to each of the business scenarios.

4. The code processing method according to claim 1, characterized in that: The determining the interface proxy object of the second business module in the common logic layer according to the calling request includes: Acquire identification information of the second service module from the call request; The interface proxy object of the second business module corresponding to the identification information is searched in the common logic layer.

5. The code processing method according to claim 1, characterized in that: The determining of the common code corresponding to the same service function in each group of service codes includes: Identify at least two business functions related to the application; Respectively determining the function codes in each group of the service codes for implementing the service functions; The function codes in each group of the business codes used to implement the same business function are determined as common codes.

6. The code processing method according to claim 1, characterized in that: The method further comprises: When a first basic component corresponding to a first basic function needs to implement a second basic function, the first basic component sends a function call request for the second basic function to the common logic layer; According to the function call request, a second basic component corresponding to the second basic function is called through the common logic layer.

7. The code processing method according to claim 1, characterized in that: The method further comprises: Get the new business code of the new business scenario; When the new service code includes the common code, the common code in the new service code is modified into a calling code for calling the public logic layer.

8. A code processing device, characterized in that: include: an acquisition unit configured to acquire original program code of an application and determine at least two business scenarios related to the application; Splitting the original program code to obtain a business code corresponding to each of the business scenarios; establishing a business module layer including at least two business modules, and determining a business correspondence between the business modules and the business scenarios; saving the business code to the business module corresponding to the business scenario according to the business correspondence, where different business scenarios refer to usage scenarios of the application program under different business environments on the same type of terminal device; establishing an interface implementation object for providing a callable interface in each of the business modules; as well as Determine at least two basic functions related to the application, establish a basic component layer including basic components, and determine a component correspondence between the basic components and the basic functions; The basic codes of the basic functions are respectively saved in the basic components corresponding to the basic functions, and the basic codes in the business code are modified into calling codes for calling the basic components; A determination unit configured to determine a common code corresponding to the same service function in each group of service codes; An establishing unit is configured to determine a business function related to the common code; establish a common logic layer including at least two function modules, and determine a functional correspondence between the function modules and the business function; and save the common code to the function module corresponding to the business function according to the functional correspondence; Establishing interface proxy objects corresponding to each of the interface implementation objects in the common logic layer; as well as Modifying the basic code in the shared code into a calling code for calling the basic component; A modification unit, configured to modify the common code in the business code into a calling code for calling the common logic layer; Among them, the mutual calling process between each of the business modules includes: determining a first business module as a caller and a second business module as a callee; sending a calling request for the second business module to the common logic layer through the first business module; determining an interface proxy object of the second business module in the common logic layer according to the calling request; and calling an interface implementation object of the second business module through the interface proxy object of the second business module.

9. The code processing device according to claim 8, characterized in that: The device also includes: an application determining unit configured to determine at least two application programs corresponding to different program versions; The program code acquisition unit is configured to respectively acquire the original program code of each of the application programs.

10. The code processing device according to claim 8, characterized in that: The device also includes: A first splitting unit is configured to split the original program code into a program startup code for starting the application and a program running code for running the application; The second splitting unit is configured to split the program running code into business codes corresponding to each of the business scenarios.

11. The code processing device according to claim 8, characterized in that: The device also includes: an identification information obtaining unit, configured to obtain identification information of the second service module from the call request; The proxy object searching unit is configured to search the common logic layer for the interface proxy object of the second business module corresponding to the identification information.

12. The code processing device according to claim 8, characterized in that: The determining unit comprises: a program business function determination unit, configured to determine at least two business functions related to the application program; A function code determination unit, configured to respectively determine a function code in each group of the service codes for implementing the service function; The common code determining unit is configured to determine the function codes for implementing the same service function in each group of service codes as common codes.

13. The code processing device according to claim 8, characterized in that: The device also includes: A new service code acquisition unit is configured to acquire a new service code for a new service scenario; The newly added service code modification unit is configured to modify the common code in the newly added service code into a calling code for calling the common logic layer when the newly added service code includes the common code.

14. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the code processing method according to any one of claims 1 to 7 is implemented.

15. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the code processing method according to any one of claims 1 to 7 by executing the executable instructions.

Citation Information

Patent Citations

  • Unified service management method and unified service management system

    CN106301885A

  • Construction method of business scenario and construction system of business scenario

    CN109343846A

  • Distributed transaction processing method and device, electronic equipment and computer readable medium

    CN109739624A

  • Software application architecture and configuration unit thereof

    CN110413264A