Instance management method and device, electronic equipment and computer readable storage medium
By instantiating the core component templates and data templates of the software function module and establishing mapping relationships, the problem of difficult connection between data instances and component instances is solved, the efficiency and maintainability of software development are improved, and dynamic updates of component instances are realized. Automatic synchronization.
Patent Information
- Application Number
- CN202411456278.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-02-14
AI Technical Summary
In the prior art, since different component instances of the functional modules will generate data instances or update data instances, the changes in data instances are difficult to communicate with component instances, resulting in high difficulty in managing data instances and difficult to locate data failures of components.
By obtaining the core component templates and data templates of the software function module, instantiating the two, creating data instances and component instances, and then establishing a mapping relationship between the two, realizing effective management of data instances and component instances.
Improve the efficiency of software development, enhance the maintainability and scalability of software, realize dynamic updates of component instances and automatic synchronization to associated data instances, and reduce developers' software status management and user interface updates. Workload improves the software's operating performance and user experience.
Smart Images

Figure CN119441010A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software technology, and in particular to an instance management method, device, electronic device, and computer-readable storage medium. Background Art
[0002] A functional module composed of multiple components may be used in various places in the system. If the state within the functional module needs to be consistent, but the state between functional modules used in different places in the system needs to be instantiated, the current technology will cause data management to be chaotic and the structure to become complicated. Interactions such as data generation, storage, acquisition, update, and deletion will consume more resources. This is because the current technology does not uniformly manage the state information shared by different components in the functional module. The communication mechanism within different components mainly relies on the components to pass on the information layer by layer to the parent, to the child, and to the peer.
[0003] However, when data is generated, relied upon, and modified by different components, the dependencies become difficult to trace, and once a problem occurs, it is difficult to locate the fault code.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide an instance management method, apparatus, electronic device and computer-readable storage medium to at least solve the technical problem in the prior art that different component instances of a functional module will generate data instances or update data instances, but changes in data instances are difficult to link with component instances, resulting in high difficulty in data instance management and difficulty in locating component data failures.
[0006] According to one aspect of an embodiment of the present application, there is provided an instance management method, comprising: obtaining a core component template of a software function module, wherein the core component template is a code that must be relied upon to implement a user interface of the software function module; determining a data template that the core component template depends on from a state library, wherein the state library is used to store and manage software state data, and the data template is a code used when storing and managing software state data; instantiating the data template and the core component template respectively to obtain a data instance obtained by the data template after the instantiation and a component instance obtained by the core component template after the instantiation, wherein both the data instance and the component instance are objects created based on code; establishing a mapping relationship between the data instance and the component instance, and managing the data instance and the component instance according to the mapping relationship.
[0007] Optionally, obtaining a core component template of a software function module includes: obtaining N component templates of the software function module, wherein each component template is used to generate a component in the user interface of the software function module, and N is an integer greater than 1; determining the core component template from the N component templates based on dependencies between the N component templates, wherein a calling priority of the core component template is higher than any component template among the N component templates except the core component template.
[0008] Optionally, the data template and the core component template are instantiated respectively to obtain a data instance obtained by the data template after the instantiation and a component instance obtained by the core component template after the instantiation, including: creating a first object according to the object structure and / or object format predefined in the core component template; using the first object as the component instance; obtaining the instance identifier of the component instance; creating a second object according to the instance identifier of the component instance and the object structure and / or object format predefined in the data template; using the second object as the data instance.
[0009] Optionally, establishing a mapping relationship between the data instance and the component instance includes: generating a namespace parameter based on the instance identifier of the component instance; taking the information of the data template as the first parameter; and establishing a mapping relationship between the data instance and the component instance based on the namespace parameter, the first parameter and the instance identifier of the component instance included in the data instance.
[0010] Optionally, managing the data instance and the component instance according to the mapping relationship includes: when it is detected that the component instance is updated, indexing the data instance corresponding to the component instance through the mapping relationship, and performing any one of the following operations on the data instance:
[0011] Performing a data modification operation on the data instance;
[0012] Performing a data reading operation on the data instance;
[0013] Performing a data writing operation on the data instance;
[0014] Perform a data deletion operation on the data instance.
[0015] Optionally, there are multiple data instances, and the data instances and the component instances are managed according to the mapping relationship, including: extracting common logical rules between the multiple data instances; generating a target file according to the common logical rules; creating a calling relationship between the target file, the data instance and the component instance according to the mapping relationship between the data instance and the component instance; and managing the multiple data instances and the component instances according to the calling relationship.
[0016] Optionally, generating a target file according to the common logic rule includes: determining a target class according to the common logic rule, wherein an inheritance relationship exists between a plurality of the data instances and the target class; and encapsulating the target class into a file to obtain the target file.
[0017] According to another aspect of an embodiment of the present application, an instance management device is also provided, wherein the instance management device includes: an acquisition unit, used to acquire a core component template of a software function module, wherein the core component template is a code that must be relied upon to implement a user interface of the software function module; a first determination unit, used to determine a data template that the core component template depends on from a state library, wherein the state library is used to store and manage software state data, and the data template is a code used when storing and managing software state data; a first processing unit, used to instantiate the data template and the core component template respectively, to obtain a data instance obtained by the data template after the instantiation and a component instance obtained by the core component template after the instantiation, wherein both the data instance and the component instance are objects created based on code; a second processing unit, used to establish a mapping relationship between the data instance and the component instance, and manage the data instance and the component instance according to the mapping relationship.
[0018] According to another aspect of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, wherein when the computer program is executed, the device where the computer-readable storage medium is located executes the above-mentioned instance management method.
[0019] According to another aspect of the present application, an electronic device is also provided, wherein the electronic device includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned instance management method.
[0020] In this application, the core component template of the software function module is first obtained, wherein the core component template is the code that must be relied on to implement the user interface of the software function module. Then, the data template that the core component template depends on is determined from the state library, wherein the state library is used to store and manage the state data of the software, and the data template is the code used when storing and managing the state data of the software. Subsequently, the data template and the core component template are respectively instantiated to obtain the data instance obtained after the data template is instantiated and the component instance obtained after the core component template is instantiated, wherein both the data instance and the component instance are objects created based on the code. Finally, a mapping relationship between the data instance and the component instance is established, and the data instance and the component instance are managed according to the mapping relationship.
[0021] As can be seen from the above, the present application obtains the core component template and the data template, instantiates the two, creates the data instance and the component instance, and then establishes the mapping relationship between the two, thereby realizing the effective management of the data instance and the component instance. This method not only improves the efficiency of software development, but also enhances the maintainability and scalability of the software, especially when processing the user interface and state data of the software function module, it can be more flexible and efficient. Through instantiation and mapping, the dynamic update of the component instance can be realized, and it can be automatically synchronized to the associated data instance, thereby greatly reducing the workload of the developer in software state management and user interface update, improving the running performance and user experience of the software, and then solving the technical problem that different component instances of the function module in the prior art will generate data instances or update data instances, but the changes in the data instance are difficult to contact with the component instance, resulting in high difficulty in data instance management and difficult location of component data failures. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0023] Figure 1 is a flowchart of an optional instance management method according to an embodiment of the present application;
[0024] Figure 2 is a schematic diagram of an optional instance management method according to an embodiment of the present application;
[0025] Figure 3 It is a schematic diagram of an optional instance management device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] It should also be noted that the information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) collected by this application are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with the relevant laws, regulations and standards of the relevant regions, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation portals are provided for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0029] According to an embodiment of the present application, an embodiment of an instance management method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0030] Figure 1 is a flowchart of an optional instance management method according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0031] Step S101, obtaining a core component template of a software function module.
[0032] In step S101, the core component template is the code that must be relied upon to implement the user interface of the software function module.
[0033] Optionally, a function module refers to an independent part that implements a specific function in a software system. Each function module usually contains related code and resources, and can complete a specific task or service. For example, in a management system, a flowchart and a document tree can be regarded as different function modules.
[0034] Optionally, a software function module may correspond to multiple component templates, wherein the multiple component templates include at least one core component template. If a software function module needs to be generated or used, the core component template will be created regardless of the conditions. For example, a flowchart function module can be split into several or dozens of specific component templates for reasons such as code maintainability and readability. Among them, a core component template will be included, which will be created regardless of the conditions.
[0035] Step S102: determining the data template on which the core component template depends from the state library.
[0036] In step S102, the state library is used to store and manage the state data of the software, and the data template is the code used when storing and managing the state data of the software.
[0037] Optionally, a state library is a tool for storing and managing the state data of an application. Among them, the state library can be applied to front-end development to help developers manage the state data of the application (such as user information, interface status, etc.) so that these state data can be shared and updated between different components. For example, Vuex is a popular state library used in Vue applications.
[0038] Optionally, a component is the basic unit for building a user interface, usually an independent, reusable block of code that contains its own logic and style. A component can be a class component or a function component, capable of receiving input (props) and returning a UI element. For example, in Vue, each UI element can be defined as a component.
[0039] Step S103, instantiate the data template and the core component template respectively to obtain a data instance obtained after the data template is instantiated and a component instance obtained after the core component template is instantiated.
[0040] In step S103, both the data instance and the component instance are objects created based on codes.
[0041] Optionally, instantiation is the process of creating a specific object (instance) of a certain template code, wherein the template is used to generate a predefined structure or format of dynamic content.
[0042] Optionally, an instance is a concrete object created by template code. Each instance has its own characteristics, such as properties and methods, and can be operated independently of other instances.
[0043] Step S104: establishing a mapping relationship between the data instance and the component instance, and managing the data instance and the component instance according to the mapping relationship.
[0044] Optionally, in order to establish a mapping relationship between a data instance and a component instance, a data model and a component model may be defined first, wherein the data model can describe the structure and properties of the data instance, while the component model describes the function and interface of the component instance.
[0045] Specifically, the data model can be a class or a structure, including fields such as "id", "name", "type", "value", etc. The component model can also be a class or a structure, including fields such as "id", "name", "inputType", "outputType", "functionality", etc. Then, a mapping relationship is created based on the defined data model and component model, where the mapping relationship can be a database table, a hash table or other data structure, which is used to store the correspondence between data instances and component instances.
[0046] Based on the contents of the above steps S101 to S104, it can be known that in the present application, the core component template of the software function module is first obtained, wherein the core component template is the code that must be relied upon to implement the user interface of the software function module. Then, the data template that the core component template depends on is determined from the state library, wherein the state library is used to store and manage the state data of the software, and the data template is the code used when storing and managing the state data of the software. Subsequently, the data template and the core component template are respectively instantiated to obtain the data instance obtained after the data template is instantiated and the component instance obtained after the core component template is instantiated, wherein both the data instance and the component instance are objects created based on the code. Finally, a mapping relationship between the data instance and the component instance is established, and the data instance and the component instance are managed according to the mapping relationship.
[0047] As can be seen from the above, the present application obtains the core component template and the data template, instantiates the two, creates the data instance and the component instance, and then establishes the mapping relationship between the two, thereby realizing the effective management of the data instance and the component instance. This method not only improves the efficiency of software development, but also enhances the maintainability and scalability of the software, especially when processing the user interface and state data of the software function module, it can be more flexible and efficient. Through instantiation and mapping, the dynamic update of the component instance can be realized, and it can be automatically synchronized to the associated data instance, thereby greatly reducing the workload of the developer in software state management and user interface update, improving the running performance and user experience of the software, and then solving the technical problem that different component instances of the function module in the prior art will generate data instances or update data instances, but the changes in the data instance are difficult to contact with the component instance, resulting in high difficulty in data instance management and difficult location of component data failures.
[0048] In an optional embodiment, obtaining a core component template of a software function module includes: obtaining N component templates of the software function module, wherein each component template is used to generate a component in a user interface of the software function module, and N is an integer greater than 1; determining a core component template from the N component templates based on dependencies between the N component templates, wherein a calling priority of the core component template is higher than any component template among the N component templates except the core component template.
[0049] Optionally, Figure 2 is a schematic diagram of an optional instance management method according to an embodiment of the present application, such as Figure 2 As shown, the core logic includes at least the following steps:
[0050] Prepare the front-end basic code framework and state library tools;
[0051] Determine the core component template of the functional module to be developed and the data template that has dependencies with the core component template;
[0052] Instantiate the core component template and the data template respectively, and establish a mapping relationship between the component instance and the data instance during the instantiation process;
[0053] Apply component instances and data instances to implement business functions, including: using data instances to support the display function of component instances and responding to user operations; modifying data instances based on updates to component instances.
[0054] Optionally, regarding the preparation of the front-end basic code framework, the present application can use the existing front-end framework of the software program, for example, mainstream frameworks such as Vue / React commonly used in front-end applications. The following is an explanation using the Vue framework as an example.
[0055] Regarding the state library management tool, there are corresponding tools in different front-end framework ecosystems. If not, developers can develop and implement them by themselves. In this application, the core requirement of the state library management tool used is that it can centrally manage the component state data of the application, and the state library management tool can provide a certain mechanism to support the modularization of the state. This application can use the Vuex tool adapted to the Vue framework as the state library management tool.
[0056] It should be noted that modularity is a software design concept that decomposes the system into multiple independent, reusable small modules. Each module is responsible for a specific function or task, which promotes the organization, maintenance and reuse of code. Modularity can improve the readability and maintainability of the code, making software development collaboration more efficient.
[0057] Optionally, splitting a functional module into N components can improve the maintainability and readability of the code. Each component is generated based on a component template. It should be noted that the N component templates must include at least one core component template, and the core component template will be created under any conditions. In addition, the logic of the N component templates will depend on the data centrally managed by the state library. For example, the component template is a rendered image template, and the key of the image template is stored in the state library. The key of the image template can be modified through the state library management tool.
[0058] It should also be noted that the priority loading and updating of core components is crucial to improving the software's responsiveness and user experience.
[0059] In an optional embodiment, the data template and the core component template are instantiated respectively to obtain a data instance obtained after the data template is instantiated and a component instance obtained after the core component template is instantiated, including: creating a first object according to an object structure and / or object format predefined in the core component template; using the first object as a component instance; obtaining an instance identifier of the component instance; creating a second object according to the instance identifier of the component instance and an object structure and / or object format predefined in the data template; using the second object as a data instance.
[0060] Optionally, the instantiation process of a component template generally occurs when the content of a component needs to be displayed on a page of a software system. For example, assuming that the content of component A needs to be displayed on a user page, an instance of component A needs to be created according to the component template corresponding to component A.
[0061] Optionally, no matter which component templates among the N component templates need to create component instances corresponding to them, the core component template needs to be instantiated first, that is, a core component instance is created. Specifically, a first object can be created based on an object structure and / or object format predefined in the core component template, wherein the first object is essentially a code object. The created first object is used as a core component instance.
[0062] Furthermore, unlike the prior art that directly generates data instances based on data templates, the present application first obtains the instance identifier of the core component instance, and then creates a second object based on the instance identifier of the core component instance, the object structure and / or object format predefined in the data template, and uses the created second object as the data instance.
[0063] It can be seen that the data instance created according to the solution of the present application at least includes the instance identifier of the core component instance, that is, the data instance and the unique ID (instance identifier) of the core component instance are bound, thereby achieving the uniqueness of the data instance. This object-based instantiation method makes the association between data and components closer, and is also easy for developers to understand and maintain.
[0064] In an optional embodiment, a mapping relationship between a data instance and a component instance is established, including: generating a namespace parameter based on an instance identifier of the component instance; using information of a data template as a first parameter; and establishing a mapping relationship between the data instance and the component instance based on the namespace parameter, the first parameter, and the instance identifier of the component instance included in the data instance.
[0065] Optionally, the module definition function provided by the registerModule interface of the Vuex tool can be used to generate namespace parameters based on the instance identifier of the component instance, and then the template information of the data template is used as the first parameter, and then the description information for recording the mapping relationship between the data instance and the component instance is generated based on the namespace parameter, the first parameter and the instance identifier of the component instance. The establishment of the mapping relationship realizes the two-way association between data and components, so that data updates can be reflected in the components immediately, and changes in components can also quickly update data, enhancing the real-time and interactivity of the software.
[0066] In an optional embodiment, managing the data instance and the component instance according to the mapping relationship includes: when it is detected that the component instance is updated, indexing the data instance corresponding to the component instance through the mapping relationship, and performing any one of the following operations on the data instance:
[0067] Perform data modification operations on data instances;
[0068] Perform data reading operations on data instances;
[0069] Perform data writing operations on data instances;
[0070] Delete data from a data instance.
[0071] Optionally, after instantiation, the component instance of the functional module can exclusively use its own data instance, and can uniformly access the data instance without confusion with other data instances, nor will the data instances of different states be randomly distributed in each component and passed layer by layer before they can be used. Each component instance can index the corresponding data instance according to the mapping relationship, and add, delete, modify and query the data of the data instance.
[0072] It should be noted that this automated data management method reduces the manual operations of developers and improves the level of automation in software development. Especially in scenarios where the user interface needs to be updated frequently, such as online shopping, social networks, etc., it can quickly respond to user operations and improve user experience.
[0073] In an optional embodiment, the number of data instances is multiple, and the data instances and component instances are managed according to the mapping relationship, including: extracting common logical rules between multiple data instances; generating a target file according to the common logical rules; creating a calling relationship between the target file, the data instance, and the component instance according to the mapping relationship between the data instance and the component instance; and managing multiple data instances and component instances according to the calling relationship.
[0074] Optionally, there may be multiple data instances corresponding to a component instance. In this case, in order to improve the reusability of the code, the common logic rules between multiple data instances can be extracted, and then the target file can be generated based on the extracted common logic rules. On the basis of creating a mapping relationship between the data instance and the component instance, a calling relationship between the target file, the data instance and the component instance can be created, so that in the process of using the component instance, if it involves calling the common logic rules, the target file can be directly called.
[0075] It should be noted that the target file can be understood as a code for implementing common logic rules. After obtaining the target file, there is no need to retain the code for implementing common logic rules in the data instance, which can greatly simplify the number of codes. For example, 10 data instances retain some of the same code for implementing common logic rules between each other. Through the solution of this application, it is only necessary to abstract this part of the same code and retain it in the target file, thereby reducing this part of the same code from 10 copies to 1 copy.
[0076] In an optional embodiment, generating a target file according to a common logic rule includes: determining a target class according to the common logic rule, wherein an inheritance relationship exists between a plurality of data instances and the target class; and encapsulating the target class into a file to obtain the target file.
[0077] Optionally, when generating a target file, first determine the target class based on the common logic rules. Since there is an inheritance relationship between the target class and multiple data instances, it is possible to implement the common logic rules between multiple data and also associate any data instance to trigger the unique logic of the data instance. Finally, encapsulate the target class into a file format to obtain the target file.
[0078] According to another aspect of the embodiment of the present application, there is also provided an instance management device, wherein, Figure 3 As shown, the instance management device includes: an acquisition unit 301 , a first determination unit 302 , a first processing unit 303 and a second processing unit 304 .
[0079] Optionally, an acquisition unit 301 is used to acquire a core component template of a software function module, wherein the core component template is the code that must be relied upon to implement the user interface of the software function module; a first determination unit 302 is used to determine a data template that the core component template depends on from a state library, wherein the state library is used to store and manage the state data of the software, and the data template is the code used when storing and managing the state data of the software; a first processing unit 303 is used to instantiate the data template and the core component template respectively, to obtain a data instance obtained after instantiation of the data template and a component instance obtained after instantiation of the core component template, wherein both the data instance and the component instance are objects created based on code; a second processing unit 304 is used to establish a mapping relationship between the data instance and the component instance, and manage the data instance and the component instance according to the mapping relationship.
[0080] Optionally, the acquisition unit 301 includes: a first acquisition subunit and a first determination subunit. The first acquisition subunit is used to acquire N component templates of the software function module, wherein each component template is used to generate a component in the user interface of the software function module, and N is an integer greater than 1; the first determination subunit is used to determine a core component template from the N component templates according to the dependency relationship between the N component templates, wherein the calling priority of the core component template is higher than any component template other than the core component template among the N component templates.
[0081] Optionally, the first processing unit 303 includes: a first processing subunit, a second processing subunit, a second acquisition subunit, a third processing subunit and a fourth processing subunit. The first processing subunit is used to create a first object according to an object structure and / or object format predefined in a core component template; the second processing subunit is used to use the first object as a component instance; the second acquisition subunit is used to obtain an instance identifier of the component instance; the third processing subunit is used to create a second object according to the instance identifier of the component instance and an object structure and / or object format predefined in a data template; and the fourth processing subunit is used to use the second object as a data instance.
[0082] Optionally, the second processing unit 304 includes: a fifth processing subunit, a sixth processing subunit and a seventh processing subunit. The fifth processing subunit is used to generate a namespace parameter according to the instance identifier of the component instance; the sixth processing subunit is used to use the information of the data template as the first parameter; and the seventh processing subunit is used to establish a mapping relationship between the data instance and the component instance based on the namespace parameter, the first parameter and the instance identifier of the component instance included in the data instance.
[0083] Optionally, the second processing unit 304 is further configured to, when detecting that the component instance is updated, index the data instance corresponding to the component instance through the mapping relationship, and perform any one of the following operations on the data instance:
[0084] Perform data modification operations on data instances;
[0085] Perform data reading operations on data instances;
[0086] Perform data writing operations on data instances;
[0087] Delete data from a data instance.
[0088] Optionally, the number of data instances is multiple, and the second processing unit 304 includes: an eighth processing subunit, a ninth processing subunit, a tenth processing subunit, and a management subunit. Among them, the eighth processing subunit is used to extract the common logic rules between multiple data instances; the ninth processing subunit is used to generate a target file according to the common logic rules; the tenth processing subunit is used to create a calling relationship between the target file, the data instance, and the component instance according to the mapping relationship between the data instance and the component instance; the management subunit is used to manage multiple data instances and component instances according to the calling relationship.
[0089] Optionally, the ninth processing subunit includes: a first determination module and a file encapsulation module. The first determination module is used to determine the target class according to a common logic rule, wherein there is an inheritance relationship between multiple data instances and the target class; and the file encapsulation module is used to encapsulate the target class into a file to obtain the target file.
[0090] As can be seen from the above, the present application obtains the core component template and the data template, instantiates the two, creates the data instance and the component instance, and then establishes the mapping relationship between the two, thereby realizing the effective management of the data instance and the component instance. This method not only improves the efficiency of software development, but also enhances the maintainability and scalability of the software, especially when processing the user interface and state data of the software function module, it can be more flexible and efficient. Through instantiation and mapping, the dynamic update of the component instance can be realized, and it can be automatically synchronized to the associated data instance, thereby greatly reducing the workload of the developer in software state management and user interface update, improving the running performance and user experience of the software, and then solving the technical problem that different component instances of the function module in the prior art will generate data instances or update data instances, but the changes in the data instance are difficult to contact with the component instance, resulting in high difficulty in data instance management and difficult location of component data failures.
[0091] According to another aspect of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, wherein when the computer program runs, the device where the computer-readable storage medium is located executes the above-mentioned instance management method.
[0092] According to another aspect of the present application, an electronic device is also provided, wherein the electronic device includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors execute the above-mentioned instance management method.
[0093] The above-mentioned embodiments or examples disclosed in the present application are not exhaustive, but are only illustrative of some embodiments or examples, and are not intended to be specific limitations on the scope of protection disclosed in the present application. In the absence of contradiction, each step in a certain embodiment or example in the present application can be implemented as an independent example, and the steps can be combined arbitrarily. For example, the scheme after removing some steps in a certain embodiment or example can also be implemented as an independent example, and the order of the steps in a certain embodiment or example can be arbitrarily exchanged. In addition, the optional methods or optional examples in a certain embodiment or example can be combined arbitrarily; in addition, the various embodiments or examples can be combined arbitrarily, for example, some or all steps of different embodiments or examples can be combined arbitrarily, and a certain embodiment or example can be combined arbitrarily with the optional methods or optional examples of other embodiments or examples.
[0094] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0095] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0096] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0097] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0098] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0099] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0100] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. An instance management method, characterized in that: include: Obtaining a core component template of a software function module, wherein the core component template is a code that must be relied upon to implement a user interface of the software function module; Determine a data template on which the core component template depends from a state library, wherein the state library is used to store and manage the state data of the software, and the data template is a code used when storing and managing the state data of the software; Instantiating the data template and the core component template respectively to obtain a data instance obtained by the data template after the instantiation and a component instance obtained by the core component template after the instantiation, wherein both the data instance and the component instance are objects created based on code; A mapping relationship between the data instance and the component instance is established, and the data instance and the component instance are managed according to the mapping relationship.
2. The instance management method according to claim 1, characterized in that: Get the core component templates of the software function modules, including: Obtaining N component templates of the software function module, wherein each component template is used to generate a component in the user interface of the software function module, and N is an integer greater than 1; The core component template is determined from the N component templates according to the dependency relationship between the N component templates, wherein the calling priority of the core component template is higher than any component template among the N component templates except the core component template.
3. The instance management method according to claim 1, characterized in that: Instantiating the data template and the core component template respectively to obtain a data instance obtained by the data template after the instantiation and a component instance obtained by the core component template after the instantiation, including: Creating a first object according to an object structure and / or an object format predefined in the core component template; Using the first object as the component instance; Obtaining an instance identifier of the component instance; Creating a second object according to the instance identifier of the component instance and the object structure and / or object format predefined in the data template; The second object is used as the data instance.
4. The instance management method according to claim 3, characterized in that: Establishing a mapping relationship between the data instance and the component instance includes: Generate a namespace parameter according to the instance identifier of the component instance; Using the information of the data template as a first parameter; A mapping relationship between the data instance and the component instance is established based on the namespace parameter, the first parameter, and the instance identifier of the component instance included in the data instance.
5. The instance management method according to claim 1, characterized in that: Managing the data instance and the component instance according to the mapping relationship includes: When it is detected that the component instance is updated, the data instance corresponding to the component instance is indexed through the mapping relationship, and any one of the following operations is performed on the data instance: Performing a data modification operation on the data instance; Performing a data reading operation on the data instance; Performing a data writing operation on the data instance; Perform a data deletion operation on the data instance.
6. The instance management method according to claim 1, characterized in that: There are multiple data instances, and managing the data instances and the component instances according to the mapping relationship includes: Extracting common logic rules between a plurality of the data instances; Generate a target file according to the common logic rules; Creating a calling relationship among the target file, the data instance and the component instance according to the mapping relationship between the data instance and the component instance; A plurality of the data instances and the component instances are managed according to the calling relationship.
7. The instance management method according to claim 6, characterized in that: Generating a target file according to the common logic rules includes: Determining a target class according to the common logic rule, wherein an inheritance relationship exists between a plurality of the data instances and the target class; The target class is encapsulated as a file to obtain the target file.
8. An instance management device, characterized in that: include: An acquisition unit, used for acquiring a core component template of a software function module, wherein the core component template is a code that must be relied upon to implement a user interface of the software function module; A first determining unit is used to determine a data template on which the core component template depends from a state library, wherein the state library is used to store and manage state data of software, and the data template is a code used when storing and managing the state data of the software; A first processing unit is used to instantiate the data template and the core component template respectively to obtain a data instance obtained by the data template after the instantiation and a component instance obtained by the core component template after the instantiation, wherein both the data instance and the component instance are objects created based on code; The second processing unit is used to establish a mapping relationship between the data instance and the component instance, and manage the data instance and the component instance according to the mapping relationship.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located executes the instance management method according to any one of claims 1 to 7.
10. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the instance management method described in any one of claims 1 to 7.