Component management method and device based on DAG, electronic equipment and storage medium

By adopting a DAG-based component management method, the problems of unclear component hierarchy and manual maintenance of initialization order in Android componentization schemes are solved. This method achieves clear responsibilities and isolation of components, reduces startup time and maintenance costs, and improves maintainability and scalability.

CN121879831APending Publication Date: 2026-04-17HUNAN XIAOSUAN TECH INFORMATION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUNAN XIAOSUAN TECH INFORMATION CO LTD
Filing Date
2026-01-09
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing Android componentization solutions suffer from unclear component hierarchy and ambiguous component responsibilities, resulting in severe component coupling. The initialization order requires manual maintenance and is executed serially, leading to high maintenance costs. Furthermore, they cannot effectively isolate components and lack verifiable structured dependency expressions.

Method used

A DAG-based component management approach is adopted. By dividing the APP into pre-defined component hierarchies, a DAG data structure and dependency tree are constructed. The directed chain and circular chain are traversed using stack search and depth-first search to convert them into an initialization hierarchical data structure. Kotlin coroutines are used for concurrent initialization processing.

Benefits of technology

It achieves clear component hierarchy and well-defined responsibilities, complete component isolation, reduces the risk of human error, significantly reduces application startup time and maintenance costs, and improves maintainability and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121879831A_ABST
    Figure CN121879831A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of software engineering, and provides a DAG-based component management method and device, electronic equipment and a storage medium, and the method comprises the steps: carrying out the component import of an APP according to a preset component hierarchy division rule, and obtaining an imported component and an initialized dependent component list; constructing a DAG data structure and a dependency tree by a created component comprising the imported component; traversing all chains by adopting stack search and depth-first search to obtain directed chains and circular chains; converting the DAG data structure into an initialized hierarchical data structure according to a preset component hierarchical division rule, wherein the initialized hierarchical data structure is used for representing that nodes are divided according to hierarchies; and performing concurrent initialization processing on the components in the initialization hierarchical data structure by adopting a Kotlin coroutine according to an APP life cycle function. The method has the beneficial effect that the fault positioning efficiency and the application starting efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software engineering technology, and in particular to a component management method, apparatus, electronic device and storage medium based on DAG. Background Technology

[0002] Android componentization is a software architecture designed to break down a large project into multiple independent components, allowing each component to be developed, tested, debugged, and deployed independently. The mainstream Android componentization solutions currently on the market and their shortcomings are as follows:

[0003] (1) By using automated build tools, the project is divided into multiple modules. By creating a common module, each high-level module sinks its data or service interface to the common module to achieve data sharing and external services. However, the coupling between modules is relatively serious, and the initialization between modules relies on hard coding to manually control the initialization order, which is too costly to maintain.

[0004] (2) With the help of ARoute, the component is scanned and processed by APT at compile time to add the routing table, and the component service is obtained through reflection; a public module also needs to be created to realize data sharing and external services, which is similar to scheme (1).

[0005] (3) Use the Startup framework based on Directed Acyclic Graph (DAG) provided by Android to manage the initialization order between components; however, this framework is only a library for managing the initialization order and only supports sequential initialization, not concurrent initialization.

[0006] The existing technology has the following drawbacks: the component hierarchy is not clear and the responsibilities of the components are not well defined, resulting in severe component coupling and inability to effectively isolate them; the component initialization order needs to be manually maintained and is mostly executed in a serial manner, resulting in long application startup time and high maintenance costs; there is a lack of verifiable structured dependency expression forms, and when the initialization order is written incorrectly, it cannot provide effective error information to help quickly locate the problem. Summary of the Invention

[0007] In order to at least solve one of the technical problems existing in the prior art, the present invention provides a component management method, apparatus, electronic device and storage medium based on DAG.

[0008] One aspect of the present invention provides a DAG-based component management method, comprising:

[0009] Import components into the APP according to the preset component hierarchy rules to obtain a list of imported components and initialization dependent components;

[0010] A DAG data structure and a dependency tree are constructed using the created components that include the imported components, wherein the DAG data structure uses the created components as nodes and the initial dependency list of the created components as edges; and the dependency tree uses the created components as the root node.

[0011] All chains are traversed using stack search and depth-first search to obtain directed chains and circular chains;

[0012] The DAG data structure is converted into an initialization hierarchical data structure according to the preset component hierarchy division rules. The initialization hierarchical data structure is used to represent the division of nodes according to hierarchy.

[0013] Based on the APP lifecycle functions, Kotlin coroutines are used to perform concurrent initialization of components in the initialization hierarchy data structure.

[0014] According to the DAG-based component management method, the added APP is imported into components according to a preset component hierarchy division rule, including:

[0015] The app is divided into an application layer, UI layer, data layer, and basic component layer according to a preset component hierarchy rule;

[0016] The imported components and the list of initial dependency components are configured using an automated build tool, and a Provider class is configured for each component, which is used for data access.

[0017] According to the DAG-based component management method, the method further includes:

[0018] The components are divided into component levels according to the preset component level division rules to obtain the component level division level;

[0019] Based on the component hierarchy, the following processing is performed on the component hierarchy:

[0020] Lower-level components should not be imported into higher-level components;

[0021] Cross-importing of components is prohibited between any two layers: the application layer, the UI layer, and the data layer.

[0022] The application layer, UI layer, and data layer can only import components that are at a lower level than themselves;

[0023] Components cannot create or call the initialization methods of other components. Components can only be created and installed in the application layer. Component initialization is automatically managed by the component container.

[0024] According to the DAG-based component management method, the construction of a DAG data structure and dependency tree using created components including the imported components includes:

[0025] The created components are used as nodes in the DAG data structure, and also as the root nodes of the dependency tree;

[0026] Add the initialization dependency list of the created component to the edge of the DAG data structure, and remove the node of the component initialization edge from the root node list of the dependency tree.

[0027] According to the DAG-based component management method, stack search and depth-first search are used to traverse all chains to obtain directed chains and circular chains, including:

[0028] Use stack search and depth-first search to traverse all dependency trees in the root node list to obtain all directed chains. If the same node exists when the directed chain changes, the directed chain is marked as a circular chain.

[0029] Traverse all directed chains. If a circular chain exists, treat it as an exception and export it.

[0030] According to the DAG-based component management method, the DAG data structure is converted into an initialization hierarchical data structure according to a preset component hierarchy partitioning rule, including:

[0031] Create a Map data structure from a valid DAG data structure, with the level as the key and the list of nodes at each level as the value. The valid DAG data structure is the DAG data structure that does not generate anomalies.

[0032] The breadth-first search algorithm is used to traverse all dependency trees in the root node list, and all nodes are stored in the corresponding values ​​according to their level to obtain the initial hierarchical data structure.

[0033] According to the DAG-based component management method, based on the APP lifecycle function, Kotlin coroutines are used to perform concurrent initialization of components in the initialization hierarchy data structure, including:

[0034] A component container is used to maintain the component list and DAG data structure. When the APP lifecycle function is triggered, the component container automatically builds and detects the DAG data structure and uses Kotlin coroutines to perform concurrent initialization of the components in the initialization hierarchy data structure.

[0035] Another aspect of the present invention discloses a DAG-based component management device, comprising:

[0036] The first module is used to import components into the APP according to the preset component hierarchy rules, and obtain the list of imported components and the initialization dependent components.

[0037] The second module is used to construct a DAG data structure and a dependency tree with the created components including the imported components, wherein the DAG data structure uses the created components as nodes and the initial dependency list of the created components as edges; wherein the dependency tree uses the created components as root nodes.

[0038] The third module is used to traverse all chains using stack search and depth-first search to obtain directed chains and circular chains.

[0039] The fourth module is used to convert the DAG data structure into an initialization hierarchical data structure according to the preset component hierarchy division rules. The initialization hierarchical data structure is used to represent the division of nodes according to hierarchy.

[0040] The fifth module is used to perform concurrent initialization of components in the initialization hierarchy data structure using Kotlin coroutines, based on the APP lifecycle functions.

[0041] Another aspect of the present invention provides an electronic device, including a processor and a memory;

[0042] The memory is used to store programs;

[0043] The processor executes the program to implement the method as described above.

[0044] This invention also discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform the methods described above.

[0045] The beneficial effects of this invention are as follows: by formulating component hierarchy and constraint rules, and designing an interaction mechanism between Provider (data interaction) components, the component hierarchy is clear, responsibilities are well-defined, and each component is completely isolated, resulting in a qualitative improvement in maintainability and scalability; by using DAG technology, the original manually controlled initialization process is transformed into automated control, and creation verification and illegal initialization dependency verification are provided to reduce the risk of human error; by using DAG technology, the initialization dependency relationship is transformed into a hierarchical relationship, and the sequential initialization of components at the same level by concurrent initialization of components at different levels significantly reduces application startup time. Attached Figure Description

[0046] Figure 1 This is a schematic diagram of the component management process based on DAG according to an embodiment of the present invention.

[0047] Figure 2 This is a multi-project component import relationship diagram according to an embodiment of the present invention.

[0048] Figure 3 This is a schematic diagram of a DAG-based component management device according to an embodiment of the present invention. Detailed Implementation

[0049] The embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings. Throughout the description, the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions. In the following description, suffixes such as "module," "part," or "unit" used to denote elements are used only for the purpose of illustrative purposes and have no specific meaning in themselves. Therefore, "module," "part," or "unit" can be used interchangeably. Terms such as "first," "second," etc., are used only to distinguish technical features and should not be construed as indicating or implying relative importance, or implicitly indicating the number of indicated technical features, or implicitly indicating the sequential relationship of the indicated technical features. In the following description, the consecutive reference numerals for method steps are for ease of review and understanding. Adjusting the implementation order of steps, in conjunction with the overall technical solution of the present invention and the logical relationship between the various steps, will not affect the technical effect achieved by the technical solution of the present invention. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0050] refer to Figure 1 , Figure 1 This is a schematic diagram of the component management process based on DAG according to an embodiment of the present invention, which includes, but is not limited to, steps S100~S500:

[0051] S100: Import components into the APP according to the preset component hierarchy rules to obtain a list of imported components and initialization dependent components;

[0052] In some embodiments, the APP is divided into an application layer, a UI layer, a data layer, and a basic component layer according to a preset component hierarchy division rule; the imported components and the list of initial dependent components are configured using an automated build tool, and a Provider class is configured for each component, wherein the Provider class is used for data access.

[0053] In some embodiments, the APP is divided into four layers: application layer, UI layer, data layer, and basic component layer, with the UI layer and data layer collectively referred to as the business layer; the UI layer, data layer, and basic component layer, excluding the application layer, are all components; this application abstracts components as Component, and each component needs to configure the list of components imported by its own component through an automated build tool (such as Gradle) (fun importComponents():Set <Class<out Component<*> >>) and a list of components that need to be configured to depend on each other (components called in their own component lifecycle functions) (funinitializeDependencies(): Set <Class<out Component<*> >>), and each component provides a class called Provider to provide services to the outside world or to obtain external data that it needs to depend on;

[0054] In addition, to achieve isolation between components, this application defines mandatory rules for each layer of components. The component hierarchy and import relationships in the project implemented according to these rules are as follows: Figure 2 As shown.

[0055] The mandatory rules are as follows:

[0056] (1) The component hierarchy from high to low is: application layer, UI layer, data layer, basic component layer;

[0057] (2) The application layer is responsible for the creation and assembly of components, and the creation and scheduling of component providers; the UI layer is responsible for calling the data layer to implement UI rendering according to business; the data layer is responsible for data operations such as data acquisition, assembly, processing, storage and forwarding; the basic component layer is only responsible for the encapsulation and management of basic capabilities and is prohibited from doing business-related work.

[0058] (3) Importing high-level components into low-level components is prohibited;

[0059] (4) Cross-importing between the application layer, UI layer and data layer is prohibited; for example, UI layer component A cannot import UI layer component B, and vice versa; interaction between components in the same layer can only be achieved by providing services or interfaces in the Provider of its own component, and the application layer calls the service or implements the interface to complete the interaction between components in the same layer, thereby achieving component isolation.

[0060] (5) The application layer, UI layer, and data layer can only import components that are lower than their own level; the basic component layer can cross-import; other components imported by the component itself through the automated build tool need to be configured in Component; if the component itself calls the service of the imported component during initialization, the component also needs to be configured in the list of components that depend on the other party to be initialized first.

[0061] (6) No component can create or call the initialization method of other components. Components can only be created and installed in the application layer. Initialization is automatically managed by the component container.

[0062] In some embodiments, the component container compares the imported components (importComponents()) of all created components with the created components, and records all imported but not created components in the uncreated list. If the uncreated list is not empty, an exception (NotCreatedException) will be thrown to help developers locate the fault.

[0063] S200, construct a DAG data structure and a dependency tree with the created components including the imported components, wherein the DAG data structure uses the created components as nodes and the initial dependency list of the created components as edges; wherein the dependency tree uses the created components as the root node.

[0064] In some embodiments, the created component is used as a node in the DAG data structure and also as the root node of the dependency tree; the initialization dependency list of the created component is added as an edge of the DAG data structure, while the node of the component initialization edge is removed from the root node list of the dependency tree.

[0065] In some embodiments, the automated inspection and management initialization process abstracts the following data structure:

[0066] Node: Used to store the component node and the list of edge nodes that it depends on, which are initialized first;

[0067] Directed Acyclic Graph (DAG): Used to store a list of all component nodes and a list of root nodes of the component initialization dependency tree;

[0068] When a node is added to a DAG, that node will also be used as the root node of the initial dependency tree.

[0069] When an initialization dependency edge is added to a DAG, the node that has become an initialization dependency edge of other nodes will be removed from the root node list of the component initialization dependency tree, so that the list only contains the root nodes of the tree.

[0070] Chain: Designed based on a stack data structure, it is used to store the linear path formed in a DAG by starting from a root node and gradually expanding downwards along the dependencies; at the same time, it will check whether the chain is a circular chain when nodes are pushed and popped from the stack.

[0071] In another embodiment, all created components are added as nodes of the DAG and used as the root nodes of the tree; the initialization dependency lists of all created components are added as edges of the DAG, while the nodes of the initialization edges of other components are removed from the root node list of the tree to ensure that the root node list always only stores the root node; for example, if component A depends on components B and C to be initialized first, then two edges B-->A and B-->C will be generated.

[0072] S300 uses stack search and depth-first search to traverse all chains, obtaining directed chains and circular chains.

[0073] In some embodiments, all directed chains are obtained by traversing all dependency trees in the root node list using stack search and depth-first search. If the same node exists when a directed chain changes, the directed chain is marked as a circular chain. All directed chains are traversed, and if a circular chain exists, it is treated as an exception and exported.

[0074] In some embodiments, all chains in the DAG data structure (including chains with only one node) are obtained: all directed chains are obtained by traversing all trees in the root node list using a stack + depth-first search algorithm; when a chain changes, it is checked whether there are identical nodes in the chain, and if so, the chain is marked as a circular chain; all chains are checked for circular chains: all directed chains are traversed, and if a circular chain exists, a CyclicDependenciesException is thrown, and all circular chains are printed for developers to troubleshoot and locate the problem.

[0075] S400 converts the DAG data structure into an initialization hierarchical data structure according to the preset component hierarchy division rules. The initialization hierarchical data structure is used to represent the division of nodes according to hierarchy.

[0076] In some embodiments, a Map data structure is created by using the level as the key and the list of nodes at each level as the value of a valid DAG data structure, wherein the valid DAG data structure is a DAG data structure that does not generate anomalies; a breadth-first search algorithm is used to traverse all dependency trees in the root node list, and all nodes are stored in the corresponding values ​​according to their levels to obtain the initialized level data structure.

[0077] In some embodiments, a valid DAG is converted into an ordered, initialized hierarchical data structure: a Map is created. <Int,List <node>The data structure uses the hierarchy as the key, with a list of nodes for each hierarchy. <node>The value is ); the breadth-first search algorithm is used to traverse all trees in the root node list and store all nodes in the corresponding value according to the level, thus obtaining a hierarchical node; this application regards nodes located in different trees and different levels as nodes that can only be initialized in hierarchical order, while nodes located in different trees and having the same level are regarded as nodes that can be initialized concurrently.

[0078] S500 uses Kotlin coroutines to perform concurrent initialization of components in the initialization hierarchy data structure, based on the APP lifecycle functions.

[0079] In some embodiments, a component container is used to maintain a component list and a DAG data structure. When the APP lifecycle function is triggered, the component container automatically builds and detects the DAG data structure and uses Kotlin coroutines to perform concurrent initialization processing on the components in the initialization hierarchy data structure.

[0080] In some embodiments, when a lifecycle function is triggered, Kotlin coroutines are used to initialize components at different levels sequentially, and a strategy of concurrent initialization at the same level is employed to distribute the lifecycle function call to all components. Specifically, this embodiment of the invention uses a component container, which internally maintains a list of components and a DAG data structure, and provides a build function and some suspend functions that match the Android Application lifecycle functions. Developers only need to add instances of components built according to component constraint rules to the component container, then call the component container's buildDAG() function in AndroidApplication's onCreate(), and call the corresponding component container lifecycle functions in other lifecycle functions to complete the creation, installation, and use of components and the component container. When the onCreate() lifecycle function is triggered, the component container will automatically start building and detecting the DAG, and finally convert the DAG into an ordered initialization hierarchy data structure. Finally, the corresponding Provider for each component is created and configured according to business needs.

[0081] In some embodiments, after the components are re-disassembled according to this application, a structure is formed as follows: Figure 2 The diagram shown is a unidirectional component import relationship diagram, which makes the structure clearer and more concise. Each component only needs to care about the components it needs to import and depend on that have been initialized by others. The component provider provides services to the outside world and defines the data that the component depends on or the configuration that can be customized by the outside world. This not only isolates the components but also unifies the component code style. When the team is developing collaboratively, the component boundaries are clearer and the code conflicts are significantly reduced. This not only improves the maintainability and scalability of the components but also improves the efficiency of team collaboration.

[0082] A DAG construction experiment was conducted on 10+ basic components and 10+ business components. The system was able to accurately generate a complete component initialization dependency graph and correctly identify imported but not created components and circular dependencies.

[0083] Concurrent initialization was tested in a production environment, and the results show that:

[0084] (1) Components at the same level can be safely initialized concurrently. Because with the help of coroutines, when only the main thread scheduler (Dispatchers.Main) is used, there is no need to consider data competition, which is both safe and efficient.

[0085] The overall initialization time was reduced by an average of 28% compared to the serial approach, from 270ms to 194ms; significantly improving the execution efficiency during the startup phase.

[0086] Figure 3 This is a schematic diagram of a DAG-based component management device according to an embodiment of the present invention. The device includes a first module 310, a second module 320, a third module 330, a fourth module 340, and a fifth module 350.

[0087] The system comprises five modules: First, importing components into the app according to a preset component hierarchy, resulting in a list of imported components and their initial dependencies. Second, constructing a Directed Acyclic Graph (DAG) data structure and a dependency tree using the imported components and their created components. The DAG uses created components as nodes and their initial dependencies as edges; the dependency tree uses created components as root nodes. Third, traversing all chains using stack search and depth-first search to obtain directed chains and circular chains. Fourth, converting the DAG data structure into an initialization hierarchy data structure according to the preset component hierarchy, representing the hierarchical division of nodes. Fifth, using Kotlin coroutines to perform concurrent initialization of components in the initialization hierarchy data structure based on the app's lifecycle functions.

[0088] For example, with the cooperation of the first, second, third, fourth, and fifth modules in the device, the embodiment device can implement any of the aforementioned DAG-based component management methods, namely, importing components into the APP according to a preset component hierarchy division rule to obtain a list of imported components and initialization dependent components; constructing a DAG data structure and a dependency tree using the created components including the imported components, wherein the DAG data structure uses the created components as nodes and the initialization dependency list of the created components as edges; wherein the dependency tree uses the created components as root nodes; traversing all chains using stack search and depth-first search to obtain directed chains and circular chains; converting the DAG data structure into an initialization hierarchy data structure according to the preset component hierarchy division rule, wherein the initialization hierarchy data structure is used to represent the division of nodes according to hierarchy; and using Kotlin coroutines to perform concurrent initialization processing on the components in the initialization hierarchy data structure according to the APP lifecycle function. The beneficial effects of this invention are as follows: by formulating component hierarchy and constraint rules, and designing an interaction mechanism between Provider (data interaction) components, the component hierarchy is clear, responsibilities are well-defined, and each component is completely isolated, resulting in a qualitative improvement in maintainability and scalability; by using DAG technology, the original manually controlled initialization process is transformed into automated control, and creation verification and illegal initialization dependency verification are provided to reduce the risk of human error; by using DAG technology, the initialization dependency relationship is transformed into a hierarchical relationship, and the sequential initialization of components at the same level by concurrent initialization of components at different levels significantly reduces application startup time.

[0089] This invention also provides an electronic device, which includes a processor and a memory;

[0090] The memory stores the program;

[0091] The processor executes a program to perform the aforementioned DAG-based component management method; the electronic device has the function of carrying and running the DAG-based component management software system provided in the embodiments of the present invention, such as a personal computer, minicomputer, mainframe, workstation, network or distributed computing environment, standalone or integrated computer platform, or communicating with charged particle tools or other imaging devices, etc.

[0092] This invention also provides a computer-readable storage medium storing a program that is executed by a processor to implement the DAG-based component management method described above.

[0093] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order shown in the operation diagrams. For example, depending on the functions / operations involved, two consecutively shown blocks may actually be executed substantially simultaneously, or the blocks may sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of this invention are provided by way of example to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented in the embodiments of this invention. Alternative embodiments are contemplated, in which the order of various operations is changed and sub-operations described as part of a larger operation are executed independently.

[0094] This invention also discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform the aforementioned DAG-based component management method.

[0095] Furthermore, although the invention has been described in the context of functional modules, it should be understood that, unless otherwise stated, one or more of the described functions and / or features may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the invention. Rather, considering the properties, functions, and internal relationships of the various functional modules in the apparatus disclosed in the embodiments of the invention, the actual implementation of the module will be understood within the scope of conventional skill of an engineer. Therefore, those skilled in the art can implement the invention as set forth in the claims using ordinary techniques without excessive experimentation. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the invention, which is determined by the full scope of the appended claims and their equivalents.

[0096] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0097] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can include, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0098] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0099] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0100] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0101] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

[0102] The above is a detailed description of the preferred embodiments of the present invention, but the present invention is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention, and these equivalent modifications or substitutions are all included within the scope defined by the claims of this application.< / node> < / node>

Claims

1. A component management method based on DAG, characterized in that, include: Import components into the APP according to the preset component hierarchy rules to obtain a list of imported components and initialization dependent components; A DAG data structure and a dependency tree are constructed using the created components that include the imported components, wherein the DAG data structure uses the created components as nodes and the initial dependency list of the created components as edges; The dependency tree uses the already created components as the root node; All chains are traversed using stack search and depth-first search to obtain directed chains and circular chains; The DAG data structure is converted into an initialization hierarchical data structure according to the preset component hierarchy division rules. The initialization hierarchical data structure is used to represent the division of nodes according to hierarchy. Based on the APP lifecycle functions, Kotlin coroutines are used to perform concurrent initialization of components in the initialization hierarchy data structure.

2. The component management method based on DAG according to claim 1, characterized in that, The process of importing components into the added app according to a preset component hierarchy rule includes: The app is divided into an application layer, UI layer, data layer, and basic component layer according to a preset component hierarchy rule; The imported components and the list of initial dependency components are configured using an automated build tool, and a Provider class is configured for each component, which is used for data access.

3. The component management method based on DAG according to claim 2, characterized in that, The method further includes: The components are divided into component levels according to the preset component level division rules to obtain the component level division level; Based on the component hierarchy, the following processing is performed on the component hierarchy: Lower-level components should not be imported into higher-level components; Cross-importing of components is prohibited between any two layers: the application layer, the UI layer, and the data layer. The application layer, UI layer, and data layer can only import components that are at a lower level than themselves; Components cannot create or call the initialization methods of other components. Components can only be created and installed in the application layer. Component initialization is automatically managed by the component container.

4. The component management method based on DAG according to claim 1, characterized in that, The construction of the DAG data structure and dependency tree using the created components including the imported components includes: The created components are used as nodes in the DAG data structure, and also as the root nodes of the dependency tree; Add the initialization dependency list of the created component to the edge of the DAG data structure, and remove the node of the component initialization edge from the root node list of the dependency tree.

5. The DAG-based component management method according to claim 4, characterized in that, The method employs stack search and depth-first search to traverse all chains, resulting in directed chains and circular chains, including: Use stack search and depth-first search to traverse all dependency trees in the root node list to obtain all directed chains. If the same node exists when the directed chain changes, the directed chain is marked as a circular chain. Traverse all directed chains. If a circular chain exists, treat it as an exception and export it.

6. The component management method based on DAG according to claim 5, characterized in that, The process of converting the DAG data structure into an initialization hierarchical data structure according to a preset component hierarchy partitioning rule includes: Create a Map data structure from a valid DAG data structure, with the level as the key and the list of nodes at each level as the value. The valid DAG data structure is the DAG data structure that does not generate anomalies. The breadth-first search algorithm is used to traverse all dependency trees in the root node list, and all nodes are stored in the corresponding values ​​according to their level to obtain the initial hierarchical data structure.

7. The component management method based on DAG according to claim 6, characterized in that, The process of using Kotlin coroutines to perform concurrent initialization of components in the initialization hierarchy data structure based on the APP lifecycle functions includes: A component container is used to maintain the component list and DAG data structure. When the APP lifecycle function is triggered, the component container automatically builds and detects the DAG data structure and uses Kotlin coroutines to perform concurrent initialization of the components in the initialization hierarchy data structure.

8. A component management device based on DAG, characterized in that, include: The first module is used to import components into the APP according to the preset component hierarchy rules, and obtain the list of imported components and the initialization dependent components. The second module is used to construct a DAG data structure and a dependency tree with the created components including the imported components, wherein the DAG data structure uses the created components as nodes and the initialization dependency list of the created components as edges. The dependency tree uses the already created components as the root node; The third module is used to traverse all chains using stack search and depth-first search to obtain directed chains and circular chains. The fourth module is used to convert the DAG data structure into an initialization hierarchical data structure according to the preset component hierarchy division rules. The initialization hierarchical data structure is used to represent the division of nodes according to hierarchy. The fifth module is used to perform concurrent initialization of components in the initialization hierarchy data structure using Kotlin coroutines, based on the APP lifecycle functions.

9. An electronic device, characterized in that, Including the processor and memory; The memory is used to store programs; The processor executes the program to implement the DAG-based component management method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The storage medium stores a program that is executed by a processor to implement the DAG-based component management method as described in any one of claims 1-7.