File Processing Method, Device, Electronic Device and Computer Readable Storage Medium

By obtaining the string collection of code files and generating access protocols, the dependencies between code files are resolved, and the problem of inefficient code decoupling in the existing technology is solved, efficient and accurate code decoupling is achieved, and maintenance costs are reduced.

CN114385159BActive Publication Date: 2025-07-29BEIJING TAOYOU TIANXIA TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210032259.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-12
Publication Date
2025-07-29
Estimated Expiration
2042-01-12

AI Technical Summary

Technical Problem

The code decoupling method in the prior art is inefficient, resulting in high code maintenance costs, error-prone and difficult to troubleshoot problems.

Method used

By obtaining the string set of code files and calculating the intersection information, an access protocol is generated to undo the dependencies between code files and generate the target code file.

Benefits of technology

Efficient and accurate code decoupling is achieved, reducing maintenance costs and reducing bug generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114385159B_ABST
    Figure CN114385159B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a file processing method, device, electronic device, and computer-readable storage medium, relating to the field of computer software technology. The method includes: obtaining at least two code files that are in a coupling relationship, determining a set of strings corresponding to the code files; obtaining intersection information between the string sets; wherein the intersection information indicates the coupling information between the code files; generating an access protocol based on the coupling information; wherein the access protocol is used to remove the dependency between the code files; and generating a target code file according to the access protocol. The embodiments of the present application achieve effective detection and positioning of code coupling through a string set, and generate a decoupled target code file through an access protocol, effectively improving the efficiency of code decoupling.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer software technology. Specifically, the present application relates to a file processing method, device, electronic device and computer-readable storage medium. Background Art

[0002] Coupling is a software metric that refers to the degree of information or parameter dependency between modules within a program. Software engineering dictates low coupling as a coding principle, meaning each module should perform a specific sub-function as independently as possible, and interfaces between modules should be kept minimal and simple.

[0003] As the development of mobile device operating system projects progresses, new businesses will continue to be introduced, resulting in an increasing amount of code in mobile terminal applications (APPs). All codes are concentrated in one project, and changes to local code often require modifications to the code of the associated projects, resulting in longer and longer code modifications and increasingly serious code coupling between modules.

[0004] The code decoupling method in the prior art usually requires technical personnel to perform technical review and coupling troubleshooting, which results in low efficiency of code decoupling. Summary of the Invention

[0005] The embodiments of the present application provide a file processing method, device, electronic device, and computer-readable storage medium, which can solve the problem of low efficiency of code decoupling in the prior art. The technical solution is as follows:

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

[0007] Obtain at least two code files that are coupled to each other, and determine a set of strings corresponding to the code files;

[0008] Obtaining intersection information between string sets; wherein the intersection information indicates coupling information between code files;

[0009] Generate an access protocol based on the coupling information; wherein the access protocol is used to release dependencies between code files;

[0010] Generate target code files according to the access protocol.

[0011] Optionally, the string set corresponding to the code file is determined to include:

[0012] Compiling the code file to obtain a compiled file of the code file; wherein the compiled file includes a first component constituting the code and path information of the first component; wherein the path information indicates a second component on which the first component depends;

[0013] Based on the mapping relationship between the first component and the preset encoding string, the compiled file is converted into a string set.

[0014] Optionally, the above-mentioned generation of the access protocol based on the coupling information includes:

[0015] An access protocol is generated based on the coupling information and the path information; wherein the access protocol indicates operation information of the second component on which the first component depends.

[0016] Optionally, the access protocol is generated based on the coupling information and the path information, including:

[0017] determining a second component indicated by the path information, and obtaining operation information of the second component;

[0018] Generate an access protocol based on the operation information and coupling information.

[0019] Optionally, the above object code file is generated according to the access protocol, including:

[0020] Based on the mapping relationship, the string set is restored to a component set;

[0021] Generates object code files based on the access protocol and component set.

[0022] Optionally, the above method further includes:

[0023] When there is a third component that the second component depends on, the path information of the second component is added to the compiled file.

[0024] Optionally, the above method further includes:

[0025] Determine a target string set corresponding to each target code file;

[0026] When the intersection between the target string sets is empty, it is determined that there is no coupling relationship between the target code files.

[0027] According to another aspect of an embodiment of the present application, a file processing device is provided, the device comprising:

[0028] A determination module is used to obtain at least two code files that have a coupling relationship and determine a set of character strings corresponding to the code files;

[0029] An acquisition module, configured to acquire intersection information between string sets; wherein the intersection information indicates coupling information between code files;

[0030] A first generating module is used to generate an access protocol based on the coupling information; wherein the access protocol is used to remove dependencies between code files;

[0031] A second generation module for generating a target code file according to an access protocol.

[0032] Optionally, the determination module is configured to:

[0033] Compile the code file to obtain a compiled file of the code file; wherein, the compiled file includes a first component constituting the code and path information of the first component; wherein, the path information indicates a second component on which the first component depends;

[0034] Convert the compiled file into a set of strings based on the mapping relationship between the first component and the preset encoding string.

[0035] Optionally, the first generation module is configured to:

[0036] Generate an access protocol based on the coupling information and the path information; wherein, the access protocol indicates the operation information of the second component on which the first component depends.

[0037] Optionally, the first generation module is used for

[0038] Determine the second component indicated by the path information and obtain the operation information of the second component;

[0039] Generate an access protocol according to the operation information and the coupling information.

[0040] Optionally, the second generation module is configured to:

[0041] Restore the set of strings to a set of components based on the mapping relationship;

[0042] Generate a target code file based on the access protocol and the set of components.

[0043] Optionally, the apparatus further includes an adding module, configured to:

[0044] When there is a third component on which the second component depends, add the path information of the second component to the compiled file.

[0045] Optionally, the apparatus further includes a verification module, configured to:

[0046] Determine a target set of strings corresponding to each target code file;

[0047] When the intersection between the target sets of strings is empty, determine that there is no coupling relationship between the target code files.

[0048] According to another aspect of the embodiments of the present application, there is provided an electronic device, including: a memory, a processor, and a computer program stored on the memory, and the processor executes the computer program to implement the steps of the method shown in the first aspect of the embodiments of the present application.

[0049] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method shown in the first aspect of the embodiments of the present application are implemented.

[0050] According to one aspect of an embodiment of the present application, a computer program product is provided, which includes a computer program. When the computer program is executed by a processor, the steps of the method shown in the first aspect of the embodiment of the present application are implemented.

[0051] The beneficial effects of the technical solution provided by the embodiment of the present application are:

[0052] The embodiments of the present application effectively detect and locate code coupling by determining the string sets corresponding to the code files and obtaining the intersection information between the string sets, thereby obtaining coupling information between the code files. Simultaneously, an access protocol is generated based on the determined coupling information to generate a target code file. Because the access protocol can eliminate the dependencies between code files, there is no coupling relationship between the target code files, thereby achieving code file decoupling. The embodiments of the present application utilize an access protocol to replace the object access method of the original code file, achieving efficient and accurate decoupling and saving application project development costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments of the present application.

[0054] Figure 1 A schematic diagram of an application scenario of a file processing method provided in an embodiment of the present application;

[0055] Figure 2 A flowchart of a file processing method provided in an embodiment of the present application;

[0056] Figure 3 A schematic diagram of a process for determining a string set in a file processing method provided in an embodiment of the present application;

[0057] Figure 4 A schematic diagram of a process for generating an access protocol in a file processing method provided in an embodiment of the present application;

[0058] Figure 5 A schematic diagram of a process for generating a target code file in a file processing method provided in an embodiment of the present application;

[0059] Figure 6 A flowchart of an exemplary file processing method provided in an embodiment of the present application;

[0060] Figure 7 A structural schematic diagram of a file processing device provided by an embodiment of the present application;

[0061] Figure 8 A structural schematic diagram of a file processing electronic device provided by an embodiment of the present application. Specific implementation manners

[0062] The embodiments of the present application will be described below with reference to the accompanying drawings in the present application. It should be understood that the embodiments described below in conjunction with the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and do not constitute limitations on the technical solutions of the embodiments of the present application.

[0063] Those skilled in the art of the present technology can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the" and "said" used herein may also include the plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements, and / or components, but do not exclude being implemented as other features, information, data, steps, operations, elements, components, and / or their combinations supported by the art of the present technology. It should be understood that when we say that an element is "connected" or "coupled" to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" can be implemented as "A", or implemented as "B", or implemented as "A and B".

[0064] To make the purpose, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0065] Software engineering stipulates that the principle of writing code is "high cohesion, low coupling". Cohesion is the independence between code blocks, and coupling is the connection between each code block. Cohesion is a concept opposite to coupling. Generally speaking, low coupling represents high cohesion, and vice versa. Both coupling and cohesion were proposed by Larry Constantine who put forward the concept of structured design. Low coupling is a characteristic of a well-structured program, and the readability and maintainability of a program with low coupling are relatively good.

[0066] For low coupling, a simple understanding is: for a complete system, between modules, make them as independent as possible. That is to say, let each module independently complete a specific sub-function as much as possible. The interfaces between modules should be as few and simple as possible.

[0067] Code cohesion refers to the degree of tightness with which various elements within a module are combined with each other. High cohesion means that the various elements within a module are highly tightly combined with each other. So-called high cohesion means that a software module is composed of highly relevant code and is only responsible for one task, which is the so-called single responsibility principle.

[0068] As an App project continues to be developed for a longer time and more developers are involved, the code will become coupled. Unstandardized code, unclear module boundaries, and reinventing the wheel will all lead to difficult-to-understand code logic entanglement, increasing maintenance costs, and it is easy to cause bugs (program errors) inadvertently. This brings a bad user experience and also damages the company's external technical image.

[0069] The applicant found that the prior art usually uses a method of manual analysis combined with manual code modification to decouple. First, it is necessary to manually analyze the coupling relationship between codes. Sometimes, it is also necessary to draw a flowchart and conduct a technical review. After passing, developers need to manually modify each piece of code involved, separate the entangled code, and achieve the purpose of decoupling. Finally, testers also need to check whether the logic of each modification affects the business. At the same time, if a decoupling bug appears online, the time cycle from problem discovery to problem solution is long.

[0070] The inventor analyzed and concluded that the above method mainly has the following problems:

[0071] 1. Time-consuming: A large amount of time is required in the early stage to manually analyze the functions and business relationships between various modules;

[0072] 2. Error-prone: Omitting a certain line of code may cause abnormal business functions;

[0073] 3. Difficult problem troubleshooting: It is very difficult to trace back which line of code caused the modified decoupled code;

[0074] 4. High cost: It is necessary for testers to continuously check later, and decoupling may also require blocking the release to wait for a certain decoupling to be completed.

[0075] The file processing method, device, electronic device, and computer-readable storage medium provided by this application are intended to solve the above technical problems of the prior art.

[0076] The embodiment of the present application provides a file processing method, which can be implemented by a terminal or a server. The terminal or server involved in the embodiment of the present application determines the string set corresponding to the code file and obtains the intersection information between the string sets, thereby obtaining the coupling information between the code files. At the same time, an access protocol is generated according to the determined coupling information to generate a target code file; because the access protocol can release the dependency between the code files, there is no coupling relationship between the above-mentioned target code files, thereby achieving the decoupling of the code files. The embodiment of the present application can effectively reduce the maintenance cost of the code, make the code structure clearer, and reduce the generation of bugs.

[0077] The following describes several exemplary embodiments to illustrate the technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application. It should be noted that the following embodiments can refer to, draw on, or combine with each other, and the same terms, similar features, and similar implementation steps in different embodiments will not be repeated.

[0078] like Figure 1 As shown, the file processing method of this application can be applied to Figure 1 In the illustrated scenario, specifically, server 101 can obtain at least two coupled code files from client 102 to determine the string sets corresponding to the code files, and obtain intersection information between the string sets to determine the coupling information between the code files. Simultaneously, an access protocol is generated based on the coupling information, and a decoupled target code file is generated. This application achieves efficient code decoupling, effectively reducing application project development costs.

[0079] Figure 1 In the scenario shown, the above file processing method can be performed in a server, and in other scenarios, it can also be performed in a terminal.

[0080] Those skilled in the art will understand that the “terminal” used here may be a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), an MID (Mobile Internet Device), etc.; the “server” may be implemented as an independent server or a server cluster consisting of multiple servers.

[0081] The present application provides a method for processing a file. Figure 2 As shown, the method includes:

[0082] S201: Obtain at least two code files that are coupled to each other, and determine a set of character strings corresponding to the code files.

[0083] Specifically, a terminal or server for performing file processing may obtain a project file of an application from a preset storage address, wherein the project file includes at least two code files.

[0084] In some implementations, a string set corresponding to a code file may be determined based on basic element components included in the code file; each code file corresponds to a string set.

[0085] In the embodiment of the present application, taking iOS (a mobile operating system developed by Apple) project development as an example, a terminal or server used for file processing can obtain a project file from the project directory of the application, and can use all precompiled files in the project file as code files, or can use some precompiled files in the project file as code files. Each code file can correspond to a functional module of the application.

[0086] S202 , obtaining intersection information between character string sets; wherein the intersection information indicates coupling information between code files.

[0087] Specifically, a terminal or server used for file processing can obtain the overlapping parts between string sets as intersection information. The string sets are converted from basic element components in the code files. Therefore, based on the intersection information, the common element components between the code files can be determined, and the coupling information can be determined.

[0088] By abstracting the code files into a string set, the embodiment of the present application can simply take the intersection of the string set to obtain the coupling relationship between the code files, thereby achieving accurate and rapid positioning of the coupled codes.

[0089] S203: Generate an access protocol based on the coupling information; wherein the access protocol is used to release dependencies between code files.

[0090] Specifically, a terminal or server for file processing can perform protocol replacement and rewrite on the coupled code file according to the coupling information to generate an access protocol.

[0091] For example, using this method in iOS project development, access protocols uses protocol syntax. Protocol syntax can be used to declare multiple methods. As long as a class conforms to a protocol, it effectively inherits all the method declarations in the protocol. Protocol methods aren't implemented by the protocol itself; instead, they're implemented by other classes that conform to the protocol. In other words, the protocol (myProtocol) simply declares the protocol's functions and doesn't care about their specific implementation.

[0092] In an embodiment of the present application, the object access form of the original code file can be replaced by protocol-based access to release the dependency between code files.

[0093] S204: Generate a target code file according to the access protocol.

[0094] Specifically, a terminal or server used for file processing can replace the inheritance, subordination and other dependency relationships of each element component in the code file based on the access protocol, and then generate a target code file, so that there is no coupling relationship between the target code files.

[0095] The embodiments of the present application effectively detect and locate code coupling by determining the string sets corresponding to the code files and obtaining the intersection information between the string sets, thereby obtaining coupling information between the code files. Simultaneously, an access protocol is generated based on the determined coupling information to generate a target code file. Because the access protocol can eliminate the dependencies between code files, there is no coupling relationship between the target code files, thereby achieving code file decoupling. The embodiments of the present application utilize an access protocol to replace the object access method of the original code file, achieving efficient and accurate decoupling and saving application project development costs.

[0096] A possible implementation method is provided in the embodiment of the present application, such as Figure 3 As shown, the character string set corresponding to the code file in step S201 above includes:

[0097] (1) Compiling a code file to obtain a compiled file of the code file; wherein the compiled file includes a first component constituting the code and path information of the first component; wherein the path information indicates a second component on which the first component depends.

[0098] Specifically, a terminal or server used for file processing may include a code interpretation module and a business coupling analysis module; the code interpretation module performs lexical and semantic analysis on the code file to obtain a compiled file of the code file; wherein the compiled file includes element component information included in the code file, and the element component information includes a first component and path information of the first component.

[0099] In the embodiment of the present application, taking the application of this method in iOS project development as an example, the above-mentioned element component information includes first components such as classes, objects, properties, and variables, as well as path information of the above-mentioned first components. For example, when the first component is attribute A, its corresponding path information can be class B to which attribute A belongs; when the first component is class C, its corresponding path information can be class B inherited by class C.

[0100] (2) Convert the compiled file into a set of strings based on the mapping relationship between the first component and the preset encoding string.

[0101] Specifically, the business coupling analysis module can convert the element component information in the compiled file to obtain a set of strings.

[0102] In the embodiments of the present application, a mapping relationship comparison table between the encoding string and the first component can be preset. For example, a class method corresponds to the string "+", an object method corresponds to the string "-", a static C variable corresponds to the string "c_s", a static C method corresponds to the string "c_s_m", etc. The business coupling analysis module converts the compiled file into a set of strings according to the above mapping relationship comparison table.

[0103] In the embodiments of the present application, a possible implementation manner is provided. The above method further includes:

[0104] When there is a third component on which the second component depends, add the path information of the second component to the compiled file.

[0105] Specifically, when the business coupling analysis module detects that the second component depends on the third component, add both the second component and the third component to the path information of the first component.

[0106] In the embodiments of the present application, when the second component is a macro and the macro definition contains another macro, i.e., the third component, the second component needs to be expanded. The above expansion operation means adding the attributes of both the second component and the third component to the attribute information of the first component.

[0107] In the embodiments of the present application, a possible implementation manner is provided, as Figure 4 shown, generating an access protocol based on the coupling information in the above step S203 includes:

[0108] Generate an access protocol based on the coupling information and the path information; wherein, the access protocol indicates the operation information of the second component on which the first component depends.

[0109] Specifically, the terminal or server for file processing further includes a code generation module. The code generation module generates an access protocol according to the coupling information and the path information. The specific steps of generating the access protocol will be introduced in detail below.

[0110] In the embodiments of the present application, a possible implementation manner is provided. The above generating an access protocol based on the coupling information and the path information includes:

[0111] a. Determine the second component indicated by the path information and obtain the operation information of the second component.

[0112] The above-mentioned operation information is used to implement the operation logic of the second component.

[0113] b. Generate an access protocol based on the operation information and coupling information.

[0114] In an embodiment of the present application, taking the application of this method in iOS project development as an example, when the first component is Class C, its corresponding path information can be Class B, which is the second component inherited by Class C. The code generation module can customize protocol D based on Class B and then generate access protocol code. Protocol D is used to declare Class B methods. When Class C complies with protocol D, Class C has the declaration of Class B methods. Moreover, the access protocol code enables Class C to directly implement the operation logic of Class B without querying Class B through object access.

[0115] The embodiment of the present application is based on protocol access, replacing the object access form of the original code file, eliminating the dependencies between code files, thereby achieving efficient code decoupling and effectively saving the project development cost of the application.

[0116] A possible implementation method is provided in the embodiment of the present application, such as Figure 5 As shown, the above step S204 generates the target code file according to the access protocol, including:

[0117] (1) Based on the mapping relationship, the string set is restored to a component set.

[0118] Specifically, the code generation module can query through the mapping relationship comparison table to restore the string set into the component set.

[0119] (2) Generate target code files based on the access protocol and component set.

[0120] Specifically, the code generation module generates a target code file according to the restored component set based on the access protocol; wherein the target code file is a decoupled code file.

[0121] A possible implementation method is provided in an embodiment of the present application, and the above method further includes:

[0122] (1) Determine the target character string set corresponding to each target code file.

[0123] In an embodiment of the present application, a terminal or server used for file processing can verify the target code file after decoupling: a code interpretation module and a business coupling analysis module can be used to convert the target code file into a target string set.

[0124] (2) When the intersection between the target character string sets is empty, it is determined that there is no coupling relationship between the target code files.

[0125] Specifically, when the business coupling analysis module takes the intersection of the target string sets and the result is empty, it indicates that there is no overlap between the target string sets, and it is determined that there is no coupling relationship between the target code files. Thus, it can be verified that the code files have been completely decoupled, and the target code files can be directly run and compiled to complete the online deployment of the application program corresponding to the target code files.

[0126] To better understand the above file processing method, the following Figure 6 elaborates in detail an example of the file processing method of the present application, including the following steps:

[0127] S601. Obtain at least two code files having a coupling relationship.

[0128] Specifically, the terminal or server for file processing can obtain the project files of the application program from a preset storage address.

[0129] S602. Compile the code file to obtain a compiled file of the code file; wherein, the compiled file includes the first component constituting the code and the path information of the first component; the path information indicates the second component on which the first component depends.

[0130] Specifically, the terminal or server for file processing may include a code interpretation module and a business coupling analysis module; the code interpretation module performs lexical and semantic analysis on the code file to parse and obtain the compiled file of the code file; wherein, the compiled file includes the element component information included in the code file, and the element component information includes the first component and the path information of the first component.

[0131] S603. Based on the mapping relationship between the first component and the preset encoding string, convert the compiled file into a string set.

[0132] Specifically, the business coupling analysis module can convert the element component information in the compiled file to obtain a string set.

[0133] S604. Obtain the intersection information between the string sets; wherein, the intersection information indicates the coupling information between the code files.

[0134] Specifically, the business coupling analysis module can obtain the overlapping part between the string sets as the intersection information. Since the string set is converted from the basic element components in the code file, the intersection information can determine the common element components between the code files, and thus determine the coupling information.

[0135] S605. Based on the coupling information and the path information, generate an access protocol; wherein, the access protocol indicates the operation information of the second component on which the first component depends.

[0136] The terminal or server for file processing further includes a code generation module. The specific steps of generating the access protocol by the code generation module include:

[0137] (1) Determine the second component indicated by the path information and obtain operation information of the second component.

[0138] The above-mentioned operation information is used to implement the operation logic of the second component.

[0139] (2) Generate an access protocol based on the operation information and coupling information.

[0140] In an embodiment of the present application, taking the application of this method in iOS project development as an example, when the first component is Class C, its corresponding path information can be Class B, which is the second component inherited by Class C. The code generation module can customize protocol D based on Class B and then generate access protocol code. Protocol D is used to declare Class B methods. When Class C complies with protocol D, Class C has the declaration of Class B methods. Moreover, the access protocol code enables Class C to directly implement the operation logic of Class B without querying Class B through object access.

[0141] S606: Based on the mapping relationship, restore the string set to a component set.

[0142] Specifically, the code generation module can query through the mapping relationship comparison table to restore the string set into the component set.

[0143] S607: Generate a target code file based on the access protocol and the component set.

[0144] Specifically, the code generation module generates a target code file according to the restored component set based on the access protocol; wherein the target code file is a decoupled code file.

[0145] The embodiments of the present application effectively detect and locate code coupling by determining the string sets corresponding to the code files and obtaining the intersection information between the string sets, thereby obtaining coupling information between the code files. Simultaneously, an access protocol is generated based on the determined coupling information to generate a target code file. Because the access protocol can eliminate the dependencies between code files, there is no coupling relationship between the target code files, thereby achieving code file decoupling. The embodiments of the present application utilize an access protocol to replace the object access method of the original code file, achieving efficient and accurate decoupling and saving application project development costs.

[0146] The present application embodiment provides a file processing device, such as Figure 7As shown, the file processing device 70 may include: a determination module 701, an acquisition module 702, a first generation module 703 and a second generation module 704;

[0147] The determining module 701 is configured to obtain at least two code files that are coupled to each other and determine a set of character strings corresponding to the code files.

[0148] An acquisition module 702 is configured to acquire intersection information between character string sets, wherein the intersection information indicates coupling information between code files;

[0149] A first generating module 703 is configured to generate an access protocol based on the coupling information; wherein the access protocol is used to release dependencies between code files;

[0150] The second generating module 704 is configured to generate a target code file according to the access protocol.

[0151] In an embodiment of the present application, a possible implementation is provided, wherein the determining module 701 is configured to:

[0152] Compiling the code file to obtain a compiled file of the code file; wherein the compiled file includes a first component constituting the code and path information of the first component; wherein the path information indicates a second component on which the first component depends;

[0153] Based on the mapping relationship between the first component and the preset encoding string, the compiled file is converted into a string set.

[0154] In an embodiment of the present application, a possible implementation is provided, wherein the first generating module 703 is configured to:

[0155] An access protocol is generated based on the coupling information and the path information; wherein the access protocol indicates operation information of the second component on which the first component depends.

[0156] A possible implementation method is provided in the embodiment of the present application. The first generation module 703 is used to

[0157] determining a second component indicated by the path information, and obtaining operation information of the second component;

[0158] Generate an access protocol based on the operation information and coupling information.

[0159] In an embodiment of the present application, a possible implementation is provided, wherein the second generating module 704 is configured to:

[0160] Based on the mapping relationship, the string set is restored to a component set;

[0161] Generates object code files based on the access protocol and component set.

[0162] In an embodiment of the present application, a possible implementation is provided, wherein the apparatus further includes an adding module configured to:

[0163] When there is a third component that the second component depends on, the path information of the second component is added to the compiled file.

[0164] In an embodiment of the present application, a possible implementation is provided, wherein the apparatus further includes a verification module configured to:

[0165] Determine a target string set corresponding to each target code file;

[0166] When the intersection between the target string sets is empty, it is determined that there is no coupling relationship between the target code files.

[0167] The device of the embodiment of the present application can execute the method provided by the embodiment of the present application, and its implementation principle is similar. The actions performed by each module in the device of each embodiment of the present application correspond to the steps in the method of each embodiment of the present application. For the detailed functional description of each module of the device, please refer to the description in the corresponding method shown in the previous text, and will not be repeated here.

[0168] The embodiments of the present application effectively detect and locate code coupling by determining the string sets corresponding to the code files and obtaining the intersection information between the string sets, thereby obtaining coupling information between the code files. Simultaneously, an access protocol is generated based on the determined coupling information to generate a target code file. Because the access protocol can eliminate the dependencies between code files, there is no coupling relationship between the target code files, thereby achieving code file decoupling. The embodiments of the present application utilize an access protocol to replace the object access method of the original code file, achieving efficient and accurate decoupling and saving application project development costs.

[0169] In an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored on the memory. The processor executes the above-mentioned computer program to implement the steps of the file processing method. Compared with the related art, the following can be achieved: the embodiment of the present application determines the string set corresponding to the code file and obtains the intersection information between the string sets, thereby obtaining the coupling information between the code files, thereby achieving effective detection and positioning of the code coupling degree; at the same time, an access protocol is generated according to the determined coupling information to generate a target code file; because the access protocol can eliminate the dependency between the code files, there is no coupling relationship between the above-mentioned target code files, thereby achieving the decoupling of the code files. The embodiment of the present application adopts the access protocol to replace the object access method of the original code file, thereby achieving the purpose of efficient and accurate decoupling and saving the project development cost of the application.

[0170] In an alternative embodiment, an electronic device is provided, such as Figure 8 shown Figure 8 The electronic device 800 shown includes: a processor 801 and a memory 803. Among them, the processor 801 and the memory 803 are connected, such as connected through a bus 802. Optionally, the electronic device 800 may further include a transceiver 804, and the transceiver 804 may be used for data interaction between the electronic device and other electronic devices, such as data sending and / or data receiving, etc. It should be noted that in practical applications, the transceiver 804 is not limited to one, and the structure of the electronic device 800 does not constitute a limitation to the embodiments of the present application.

[0171] The processor 801 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in connection with the disclosure of the present application. The processor 801 may also be a combination that implements a computing function, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0172] The bus 802 may include a path for transmitting information between the above components. The bus 802 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 802 may be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 8 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.

[0173] The memory 803 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation here.

[0174] The memory 803 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the processor 801. The processor 801 is used to execute the computer program stored in the memory 803 to implement the steps shown in the above method embodiment.

[0175] The electronic devices include, but are not limited to, mobile terminals such as mobile phones, notebook computers, PADs, etc., and fixed terminals such as digital TVs, desktop computers, etc.

[0176] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.

[0177] The present invention provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, so that when the computer device executes the computer instructions, the following conditions are achieved:

[0178] Obtain at least two code files that are coupled to each other, and determine a set of strings corresponding to the code files;

[0179] Obtaining intersection information between string sets; wherein the intersection information indicates coupling information between code files;

[0180] Generate an access protocol based on the coupling information; wherein the access protocol is used to release dependencies between code files;

[0181] Generate target code files according to the access protocol.

[0182] The terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the description, claims and above-mentioned drawings of this application are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of this application described here can be implemented in an order other than that shown or described in words.

[0183] It should be understood that although the flowchart of the embodiments of this application indicates each operation step by an arrow, the execution order of these steps is not limited to the order indicated by the arrow. Unless there is a clear description in this article, in some implementation scenarios of the embodiments of this application, the implementation steps in each flowchart can be executed in other orders according to requirements. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage among these sub-steps or stages can also be executed at different times respectively. In the scenario where the execution times are different, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and the embodiments of this application do not limit this.

[0184] The above are only optional implementation manners of some implementation scenarios of this application. It should be noted that for those of ordinary skill in the art in this technical field, without departing from the technical concept of the solution of this application, adopting other similar implementation means based on the technical idea of this application also belongs to the protection scope of the embodiments of this application.

Claims

1. A file processing method, characterized in that: include: Obtain at least two code files that are coupled to each other, and determine a set of character strings corresponding to the code files; Obtaining intersection information between the character string sets; wherein the intersection information indicates coupling information between the code files; Generate an access protocol based on the coupling information; wherein the access protocol is used to release the dependency between the code files; Generate an object code file according to the access protocol; The step of determining the set of character strings corresponding to the code file includes: Compiling the code file to obtain a compiled file of the code file; wherein the compiled file includes a first component constituting the code and path information of the first component; wherein the path information indicates a second component on which the first component depends; Converting the compiled file into a string set based on a mapping relationship between the first component and a preset encoding string; The step of generating an access protocol based on the coupling information includes: An access protocol is generated based on the coupling information and the path information; wherein the access protocol indicates operation information of the second component on which the first component depends.

2. The method according to claim 1, characterized in that, The generating an access protocol based on the coupling information and the path information includes: determining the second component indicated by the path information, and obtaining operation information of the second component; An access protocol is generated according to the operation information and the coupling information.

3. The method according to claim 1, characterized in that Generating the target code file according to the access protocol includes: Based on the mapping relationship, the string set is restored to a component set; The object code file is generated based on the access protocol and the component set.

4. The method according to claim 1, characterized in that: The method further comprises: When there is a third component on which the second component depends, the path information of the second component is added to the compiled file.

5. The method according to claim 1, characterized in that, The method further comprises: Determining a target character string set corresponding to each of the target code files; When the intersection between the target character string sets is empty, it is determined that there is no coupling relationship between the target code files.

6. A file processing device, characterized in that, include: A determination module, configured to obtain at least two code files having a coupling relationship and determine a set of character strings corresponding to the code files; An acquisition module, configured to acquire intersection information between the character string sets; wherein the intersection information indicates coupling information between the code files; A first generating module, configured to generate an access protocol based on the coupling information; wherein the access protocol is used to release the dependencies between the code files; A second generating module is used to generate a target code file according to the access protocol; The determining module is specifically configured to: Compiling the code file to obtain a compiled file of the code file; wherein the compiled file includes a first component constituting the code and path information of the first component; wherein the path information indicates a second component on which the first component depends; Converting the compiled file into a string set based on a mapping relationship between the first component and a preset encoding string; The first generating module is specifically configured to: Generate an access protocol based on the coupling information and the path information; wherein the access protocol indicates the operation information of a second component upon which the first component depends.

7. An electronic device, comprising a memory, a processor, and a computer program stored on the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1-5 are implemented.

Citation Information

Patent Citations

  • Information processing method and device and electronic equipment

    CN112181429A

  • Transaction data processing method and device and computer equipment

    CN112508573A

  • Application program modularization method and device, application program component calling method and device, application program component initialization method and device

    CN112698888A