An application generation method and device, electronic equipment and storage medium
By constructing the association between the main control class and the sub-control classes through the SCR model, and using interface classes and extended base classes to achieve decoupling, the problem of strong coupling between the main class and the sub-class is solved, and the maintainability and scalability of the application are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 粤港澳大湾区(广东)国创中心
- Filing Date
- 2025-04-24
- Publication Date
- 2026-05-08
AI Technical Summary
In existing technologies, there is a strong coupling between the main class and the sub-controller classes during application development. This means that changes to any class will affect all nodes in the entire tree, resulting in poor code maintainability and development difficulties.
A triangular relationship model based on SCR is adopted, which establishes the association between the main control class and the sub-control class through interface classes and extended base classes, thereby achieving decoupling, reducing dependencies, and managing the dynamic registration and discovery of sub-control classes through the registry.
It improves the maintainability, scalability, and development efficiency of applications, allows sub-controller classes to be modified and extended independently without affecting the main class, reduces dependencies between modules, and clarifies the division of development tasks.
Smart Images

Figure CN120469668B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software development technology, and in particular to an application generation method, an application generation apparatus, an electronic device, and a computer-readable storage medium. Background Technology
[0002] In application development, managing the relationship between the whole and its parts is often involved. For example, an application interface may contain many sub-controllers, which in turn contain many more sub-controllers, and so on, creating a tree structure. Even if this organization is based on classes (objects) with clearly defined responsibilities, the coupling between these classes (objects) extends all the way to the root node. Any change or modification to one class will affect all nodes in the entire tree. Summary of the Invention
[0003] The present invention provides an application generation method, apparatus, electronic device, and computer-readable storage medium to overcome or at least partially solve the above-mentioned problems.
[0004] This invention discloses an application generation method, comprising:
[0005] Determine the main control class and the external capability types of the main control class;
[0006] Construct an interface class based on the aforementioned external capability type;
[0007] Determine the sub-control classes for the main control class, and the general function types of the sub-control classes;
[0008] An extended base class is constructed based on the aforementioned general functions;
[0009] The association between the main control class and the sub-control class is constructed based on the interface class and the extended base class, and the application is generated based on the association.
[0010] Optionally, the step of constructing the association between the main control class and the sub-control class based on the interface class and the extended base class includes:
[0011] The sub-control class interface type information of the sub-control class is determined based on the interface class;
[0012] Construct an initial registry for the sub-control class;
[0013] The sub-control class inherited from the extended base class and the interface type information of the sub-control class are added to the initial registry to generate the sub-control class registry; the sub-control class registry is used to express the association relationship between the main control class and the sub-control class.
[0014] Optionally, it also includes:
[0015] Determine the target sub-control class;
[0016] The main control class is controlled to read the registry of the sub-control class to obtain the target interface class of the target sub-control class;
[0017] The target sub-control class is called through the target interface class.
[0018] Optionally, it also includes:
[0019] When a new sub-control class that inherits from the extended base class is obtained, the interface type information of the new sub-control class is determined based on the interface class.
[0020] Add the newly added sub-control class and its interface type information to the sub-control class registry.
[0021] Optionally, it also includes:
[0022] The newly added sub-control class is identified as the newly added main control class, and the new external capability type of the newly added main control class is determined.
[0023] Construct a new interface class based on the newly added external capability type;
[0024] Determine the subclasses of the newly added main control class, and the general function types of the subclasses of the main control class;
[0025] Based on the aforementioned general functions, a new extended base class is constructed;
[0026] Based on the newly added interface class and the newly added extended base class, a new association relationship is constructed between the newly added main control class and the newly added sub-control class, and an application is generated based on the association relationship and the newly added association relationship.
[0027] Optionally, the step of constructing the new association between the new main control class and the new grandchild control class based on the new interface class and the new extended base class includes:
[0028] Based on the newly added interface class, determine the interface type information of the grandchild control class of the grandchild control class;
[0029] Construct a new initial registry for the aforementioned grandchild control class;
[0030] The grandchild control class that inherits from the newly added extended base class and the interface type information of the grandchild control class are added to the newly added initial registry to generate the grandchild control class registry; the grandchild control class registry is used to express the association relationship between the newly added main control class and the grandchild control class.
[0031] Optionally, it also includes:
[0032] Identify the target subclass control class;
[0033] The newly added main control class is controlled to read the registry of the grandchild control class to obtain the newly added target interface class of the target grandchild control class;
[0034] The target grandchild control class is called through the newly added target interface class.
[0035] This invention also discloses an application generation method, comprising:
[0036] The main control class determination module is used to determine the main control class and the external capability type of the main control class;
[0037] An interface class construction module is used to construct interface classes based on the aforementioned external capability type;
[0038] A sub-control class determination module is used to determine the sub-control classes for the main control class, and the general function type of the sub-control classes;
[0039] An extended base class construction module is used to construct extended base classes based on the aforementioned general functions;
[0040] The association relationship construction module is used to construct the association relationship between the main control class and the sub-control class based on the interface class and the extended base class, and generate the application based on the association relationship.
[0041] This invention also discloses an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0042] The memory is used to store computer programs;
[0043] When the processor executes a program stored in the memory, it implements the method described in the embodiments of the present invention.
[0044] This invention also discloses a computer-readable storage medium storing instructions that, when executed by one or more processors, cause the processors to perform the methods described in this invention.
[0045] The embodiments of the present invention have the following advantages:
[0046] This invention, through the following embodiments, defines a main control class and its external capability types; constructs an interface class based on the external capability types; determines sub-control classes for the main control class and their general function types; constructs an extension base class based on the general functions; establishes the association between the main control class and the sub-control classes based on the interface class and the extension base class; and generates an application based on the association. By clarifying the responsibilities of the main control class and the sub-control classes and determining their association through the interface class and the extension base class, the invention achieves decoupling between the main control class and the sub-control classes, thereby improving the maintainability, scalability, and development efficiency of the application during the development phase. Attached Figure Description
[0047] Figure 1 This is a flowchart of the steps of an application generation method provided in an embodiment of the present invention;
[0048] Figure 2 This is a schematic diagram of the main architecture of an application provided in an embodiment of the present invention;
[0049] Figure 3 It is a structural relationship diagram of the main control class and sub-control classes provided by related technologies;
[0050] Figure 4 This is a structural relationship diagram of a main control class, a sub-control class, and a grandchild control class provided in an embodiment of the present invention;
[0051] Figure 5 This is a structural block diagram of an application generation device provided in an embodiment of the present invention;
[0052] Figure 6 This is a hardware structure block diagram of an electronic device provided in an embodiment of the present invention;
[0053] Figure 7 This is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. Detailed Implementation
[0054] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0055] Reference Figure 1 The diagram illustrates a flowchart of an application generation method provided in an embodiment of the present invention, which may specifically include the following steps:
[0056] Step 101: Determine the main control class and the external capability type of the main control class;
[0057] Step 102: Construct an interface class based on the external capability type;
[0058] Step 103: Determine the sub-control classes for the main control class, and the general function type of the sub-control classes;
[0059] Step 104: Construct an extended base class based on the aforementioned general functions;
[0060] Step 105: Construct the association relationship between the main control class and the sub-control class based on the interface class and the extended base class, and generate the application based on the association relationship.
[0061] refer to Figure 2 , Figure 2 This is a schematic diagram of the main architecture of an application provided in an embodiment of the present invention;
[0062] In practical applications, to address issues such as strong dependencies between the main class and sub-controller classes, rapid expansion of the main class, and difficulties in development division of labor in traditional development models, a triangular relationship model based on SCR (Sub Composite Registration) is introduced. This invention can be applied to the triangular relationship model SCR. The core concepts of the SCR model are:
[0063] Decoupling: Transform the direct reference relationship between the main class and the sub-controller classes into composition through a registration mechanism, thereby reducing their dependencies.
[0064] Independent changes: The main class and sub-controller classes can be modified and extended independently without affecting each other.
[0065] Hierarchical structure: Maintain the original hierarchical structure for easy management and maintenance.
[0066] Implementation steps of the SCR model:
[0067] Modularization: Decomposing complex composition problems into a series of independent plugins (sub-control classes).
[0068] Define a triangular relationship model: establish a triangular relationship between the main class, the interface class, and the extended base class.
[0069] Establish the association between the main control class and the sub-control class: the sub-control class provides its functionality to the main class through this association.
[0070] Interface specification: Define the services provided by the main class to the sub-controller classes through the interface class.
[0071] Extended base class: Defines the general specifications that child control classes must follow.
[0072] Core components of the SCR model:
[0073] 1. IMainController (interface class):
[0074] This is an interface that defines the methods and properties that the main controller should implement.
[0075] IMainController (interface class) contains:
[0076] field:type(field:type): Represents a data member with a specific type.
[0077] method(type):type(method(type):type): indicates a method that accepts a parameter of a specific type and returns a value of a specific type.
[0078] 2. MainController (Main Controller Class):
[0079] This is the class that implements the IMainController interface.
[0080] MainController (the main controller class) contains:
[0081] field:type(field:type): Represents a data member with a specific type.
[0082] method(type):type(method(type):type): indicates a method that accepts a parameter of a specific type and returns a value of a specific type.
[0083] 3. SubControllerBaseClass (Extended Base Class):
[0084] This is a base class for child controllers, providing common functionality for child controllers.
[0085] SubControllerBaseClass (extended base class) contains:
[0086] field:type(field:type): Represents a data member with a specific type.
[0087] method(type):type(method(type):type): indicates a method that accepts a parameter of a specific type and returns a value of a specific type.
[0088] Advantages of the SCR model:
[0089] Reduced coupling: The dependency between the main class and the sub-controller classes is reduced, which improves the maintainability and scalability of the code.
[0090] Increased flexibility: Subclasses can be modified and extended independently without affecting the main class.
[0091] Facilitates division of labor in development: Different developers can independently develop and test sub-controller classes, improving development efficiency.
[0092] Enhanced reusability: Subclasses can be reused by other main classes, improving code reusability.
[0093] In a specific implementation, embodiments of the present invention can determine the main control class and the external capability type of the main control class;
[0094] The goal is to identify the core of the application's overall management, namely the main control class. This involves identifying the functions and services that the main control class needs to provide to its sub-control classes, i.e., the types of external capabilities.
[0095] This invention lays the foundation for the overall architecture of the application by determining the main control class and the external capability types of the main control class. Clearly defining the responsibilities of the main class facilitates modular design.
[0096] In this embodiment of the invention, an interface class can be constructed based on the aforementioned external capability type;
[0097] The purpose is to abstract the external capabilities of the main control class into an interface in order to define the specifications for interaction between the sub-control classes and the main control class.
[0098] This invention, by constructing interface classes based on the aforementioned external capability types, facilitates the decoupling of the main control class and sub-control classes, reducing dependencies and improving code maintainability and scalability.
[0099] In practical applications, a main controller class can correspond to one or more sub-controller classes. For example, MainController (the main controller class) can correspond to multiple SubController1, SubController2, SubController... (sub-controller 1, sub-controller 2, sub-controller...).
[0100] These are specific sub-controller classes, which inherit from the extended base class SubControllerBaseClass.
[0101] Each child controller contains:
[0102] field:type(field:type): Represents a data member with a specific type.
[0103] method(type):type(method(type):type): indicates a method that accepts a parameter of a specific type and returns a value of a specific type.
[0104] The embodiments of the present invention can determine the sub-control classes for the main control class, and the general function type of the sub-control classes;
[0105] The purpose is to clearly define the various functional modules of the application, i.e., the sub-controller classes, and to identify the general specifications that the sub-controller classes need to follow.
[0106] This invention, by defining sub-control classes for the main control class and the general function types of the sub-control classes, promotes modular development and facilitates functional expansion. It also creates conditions for the sub-control classes to correctly integrate with the main control class.
[0107] Embodiments of the present invention can construct extended base classes based on the aforementioned general functions;
[0108] The purpose is as follows:
[0109] 1. Unify interface specifications to achieve polymorphism:
[0110] The extended base class defines a set of common methods and properties that all child control classes must implement.
[0111] This ensures that the main control class can interact with all sub-control classes through a unified interface, without needing to know the specific type of the sub-control classes.
[0112] This polymorphism makes the system more flexible, allowing for easy addition or replacement of sub-control classes without modifying the main control class code.
[0113] 2. Reduce coupling and improve maintainability:
[0114] By extending the base class, the dependency relationship between the child controller class and the main controller class is abstracted.
[0115] The main control class depends only on the interface defined by the extended base class, without directly depending on the implementation of specific sub-control classes.
[0116] This reduces the coupling between the main control class and the sub-control classes, making the code easier to maintain and modify.
[0117] 3. Improve code reusability:
[0118] Extended base classes can contain implementations of common functionalities, such as initialization, registration, and communication.
[0119] Subclasses can inherit these common functionalities, thereby reducing the writing of repetitive code.
[0120] This improves code reusability and makes development more efficient.
[0121] 4. Implement a plug-in architecture:
[0122] The extended base class provides a unified framework for the development of plugins (sub-controllers).
[0123] Plugin developers can easily integrate plugins into the system simply by inheriting from the extended base class and implementing its defined interfaces.
[0124] This makes the system highly scalable, allowing for easy addition of new features.
[0125] 5. Standardize the behavior of sub-controllers to ensure system stability:
[0126] Extending a base class allows you to define rules and constraints that child control classes must follow, such as data format and error handling.
[0127] This helps ensure that all sub-control classes behave consistently, thereby improving the stability and reliability of the system.
[0128] This invention, through the construction of an extended base class based on the aforementioned general functions, reduces repetitive code in sub-control classes, improves code reusability, simplifies sub-control class development, and reduces development costs.
[0129] The embodiments of the present invention can construct the association relationship between the main control class and the sub-control class based on the interface class and the extended base class, and generate an application based on the association relationship.
[0130] The goal is to establish an interaction between the main control class and the sub-control class by building a relationship between them, while ensuring that the main control class and the sub-control class are decoupled, so as to meet the development needs of the application.
[0131] To enable those skilled in the art to better understand the embodiments of the present invention, an example is used below to illustrate the embodiments of the present invention.
[0132] refer to Figure 3 , Figure 3 It is a structural relationship diagram of the main control class and sub-control classes provided by related technologies;
[0133] In traditional development, managing the relationship between the whole and its parts is often involved. For example, a program interface may contain many sub-controllers, and a sub-controller may also act as a main controller, containing many sub-controllers. The main controller class and the sub-controller classes have a relationship of inclusion or being included, and so on, which will create a tree. For example, we are currently developing a vehicle intelligent control application:
[0134] A car (A) directly comprises the body (B) and interior (C).
[0135] The interior (C) directly includes the large screen (D) and seats (E).
[0136] This means that if software developers want to replace the large screen (D) or add new interior components, they need to modify the code for the interior (C). At the same time, since the car (A) directly references the interior (C), the code for the car (A) also needs to be modified.
[0137] If the R&D personnel want to replace the car's chassis or add new car parts, then the R&D personnel need to modify the car's (A) code.
[0138] This direct dependency leads to strong coupling in the code, meaning that changes to any one component will affect the others.
[0139] To address the issues of strong dependencies, rapid expansion of the main class, and difficulties in development division of labor mentioned above, a triangular relationship model based on SCR is introduced. This model primarily decouples the main class and sub-controller classes, allowing them to change independently while maintaining the original hierarchical structure.
[0140] For example,
[0141] The car (A) no longer directly contains the body (B) and interior (C), but dynamically "knows" about the body (B) and interior (C) through the registry of interface classes and sub-control classes.
[0142] The interior (C) does not directly include the large screen (D) and seats (E), but rather dynamically "knows" about the large screen (D) and seats (E) through the same mechanism.
[0143] This means that researchers can independently modify or replace any component without needing to modify the code of other components.
[0144] For example, R&D personnel can replace the large screen (D) without modifying the interior (C) or the car's (A) code.
[0145] Researchers can add new car parts without modifying the car's (A) code.
[0146] To implement SCR, the original problem must first be plugged in, breaking down a series of combined problems into triangular relationships. The implementation of SCR requires defining a triangular relationship model, which consists of a main class controller, a main class interface, and an extended base class.
[0147] Specifically, the responsibilities of the main controller class (such as MainController in the diagram above) can be separated. Instead of actively referencing and maintaining the child controller classes, the common parent class of the child controller classes is referenced (this common parent class defines the interface specification for the child controller classes to connect to the main controller class). Simultaneously, the capabilities provided by the main controller class for the child controller classes are encapsulated in an interface class (such as IMainController in the diagram above). Then, all extended child controller classes that need to connect to the main controller class (in a whole-part relationship) are implemented by inheriting from the common parent class of the child controller classes (SubControllerBaseClass).
[0148] Taking a car interior management system (SCR) that does not directly include the large screen (D) and seats (E) as examples of vehicle intelligent control applications, the core components of the SCR model are:
[0149] Main controller class:
[0150] Responsible for overall management and coordination.
[0151] Instead of directly referencing and maintaining the sub-controller classes, it interacts with them through interface classes.
[0152] For example, in an automotive interior management system that acts as the main control class, the main control class is responsible for managing all interior components, such as the large screen (D) and seats (E).
[0153] Interface class (IMainController):
[0154] Define the service interface provided by the main control class to the child control class.
[0155] It only defines the behavioral specifications, without including the specific implementation.
[0156] For example, in an automotive interior management system, if the external capabilities of the main control class include power supply and lighting control, then the interface class can define interfaces such as power switch and lighting control.
[0157] Extended base class (SubControllerBaseClass):
[0158] The common parent class of all sub-controller classes defines the general specifications that the sub-controller classes must follow. For example, in an automotive interior management system, the extended base class can define unified initialization, registration, and communication methods.
[0159] For example, both the large screen (D) and the seat (E) must adhere to a unified plug specification, and only sub-control classes with three-prong plugs can be connected. This is a mandatory specification; for instance, all plugs must be three-prong plugs to connect to this common function type.
[0160] During development, all child controllers that inherit from the extended base class `SubControllerBaseClass` need to be registered in the child controller class registry. The main controller class can then access the registry to obtain information on which child controller classes have been registered. Through the extended base class `SubControllerBaseClass`, the main controller class can determine the interfaces of these child controller classes (e.g., they all need to support three-prong plugs, because all child controller classes must inherit from their common parent class `SubControllerBaseClass`). This allows the main controller class to call and manage all its child controllers. Therefore, to extend the main controller class, only a new child controller class needs to be added and registered. This ensures that modules are independent during the application development phase, and communication and interaction between modules are conducted through interfaces rather than direct calls, preventing direct dependencies between functional modules.
[0161] It should be noted that the above examples are merely illustrations, and those skilled in the art can apply the above methods to the development of applications in any field (other than vehicle control systems). In this regard, the embodiments of the present invention do not limit the scope of application development.
[0162] Furthermore, the above description of using the registration form of the sub-control class registry to implement the association relationship is merely an example. Those skilled in the art can use other methods to determine the association relationship between the main control class and the sub-control class, such as, but not limited to, the following methods.
[0163] 1. Service Locator:
[0164] Create a service locator object to manage instances of all sub-controller classes.
[0165] The main control class can obtain the required sub-control class instances through the service locator.
[0166] This approach centralizes the creation and management of sub-controller classes in one location, improving code maintainability.
[0167] 2. Dependency Injection:
[0168] Inject instances of the sub-controller class as dependencies into the main controller class.
[0169] The dependency injection framework is responsible for creating and managing instances of sub-controller classes and injecting them into the main controller class.
[0170] This approach further reduces the coupling between the main control class and the sub-control classes.
[0171] 3. Configuration Files:
[0172] Use configuration files (e.g., XML, JSON) to define the relationships between the main control class and the child control classes.
[0173] The main control class reads the configuration file at runtime and creates and manages sub-control classes based on the configuration information.
[0174] This approach allows for changes to associations without modifying the code.
[0175] 4. Routing Mechanism:
[0176] In web applications or mobile applications, routing mechanisms can be used to map requests to the appropriate sub-controllers.
[0177] The routing mechanism determines the sub-control class to be invoked based on the requested URL or other information.
[0178] This approach is often used to build modular applications.
[0179] This invention, through the following embodiments, defines a main control class and its external capability types; constructs an interface class based on the external capability types; determines sub-control classes for the main control class and their general function types; constructs an extension base class based on the general functions; establishes the association between the main control class and the sub-control classes based on the interface class and the extension base class; and generates an application based on the association. By clarifying the responsibilities of the main control class and the sub-control classes and determining their association through the interface class and the extension base class, the invention achieves decoupling between the main control class and the sub-control classes, thereby improving the maintainability, scalability, and development efficiency of the application during the development phase.
[0180] Based on the above embodiments, modified embodiments of the above embodiments are proposed. It should be noted that, in order to keep the description brief, only the differences from the above embodiments are described in the modified embodiments.
[0181] In an optional embodiment of the present invention, the step of constructing the association between the main control class and the sub-control class based on the interface class and the extended base class includes:
[0182] The sub-control class interface type information of the sub-control class is determined based on the interface class;
[0183] Construct an initial registry for the sub-control class;
[0184] The sub-control class inherited from the extended base class and the interface type information of the sub-control class are added to the initial registry to generate the sub-control class registry; the sub-control class registry is used to express the association relationship between the main control class and the sub-control class.
[0185] In a specific implementation, embodiments of the present invention can determine the sub-control class interface type information of the sub-control class based on the interface class, so as to clarify the interfaces that the sub-control class needs to implement. These interfaces define the ability of the sub-control class to interact with the main control class, and can also provide interface type information for subsequent registration, so that the main control class can perform type checking and interface calls.
[0186] By determining the interface type information of the sub-controller classes, it is ensured that the sub-controller classes conform to the interface specifications defined by the main control class, thus guaranteeing compatibility between modules. A unified interface calling method is provided for the main control class, reducing the coupling between the main control class and the sub-controller classes. Through the interface type information, the main control class can dynamically check at runtime whether the sub-controller classes implement the required interfaces.
[0187] The embodiments of the present invention can construct an initial registry for the sub-control class to create a container for storing sub-control class information, providing a basis for subsequent registration of sub-control classes.
[0188] By constructing an initial registry for the sub-control classes, the main control class is provided with a unified entry point for managing sub-control classes, while also enabling subsequent dynamic expansion.
[0189] In this embodiment of the invention, the extended base class and the sub-control class can also be added to the initial registry to generate a sub-control class registry, which can be used to express the association between the main control class and the sub-control class.
[0190] The purpose is to register all sub-control classes that inherit from the extended base class in the registry, thus establishing the association between the main control class and the sub-control classes.
[0191] In this embodiment of the invention, an initial registry for the sub-control class is constructed; the sub-control class inheriting from the extended base class and the interface type information of the sub-control class are added to the initial registry to generate a sub-control class registry; the sub-control class registry is used to express the association relationship between the main control class and the sub-control class, so that the main control class can dynamically discover and manage the sub-control class through the registry, realizing the dynamic registration and discovery of sub-control classes and improving the flexibility of the system.
[0192] During the SCR model registration process, the relationship between the interface class (IMainController) and the extended base class (SubControllerBaseClass) is reflected in the following aspects:
[0193] 1. The extended base class defines the interfaces that child control classes must implement:
[0194] The extended base class SubControllerBaseClass can define some abstract methods or interfaces that all subcontroller classes must implement.
[0195] These abstract methods or interfaces are actually the "contract" for the interaction between the sub-controller class and the main controller class.
[0196] The main controller class defines the capabilities it provides to child controller classes through the interface class IMainController, while the extended base class SubControllerBaseClass ensures that all child controller classes implement these capabilities.
[0197] Therefore, when a subcontroller class inherits from SubControllerBaseClass, it must implement these interfaces to ensure that the main controller class can call the functions of the subcontroller class through the interface class SubControllerBaseClass.
[0198] 2. The registration information includes the interface type information of the sub-controller class:
[0199] When a subcontroller class is registered, the registration information usually includes the subcontroller class interface type information implemented by the subcontroller class.
[0200] The interface type information for this sub-controller class is the interface class IMainController or its related interfaces.
[0201] When the main control class reads the registry, it can determine whether the sub-control class implements the required interface based on the interface type, thereby making the correct call.
[0202] For example, the registration information can include a Class<?>interfaceType field to store the interface type implemented by the subcontroller class.
[0203] 3. The main control class calls the sub-control class through interface classes and extended base classes:
[0204] After obtaining an instance of the sub-controller class, the main controller class will call the sub-controller class's functionality through the interface class IMainController or the extended base class SubControllerBaseClass.
[0205] Since all sub-controller classes inherit from the extended base class and implement the interfaces defined by the interface class, the main control class can call the functions of the sub-controller classes in a unified way.
[0206] This demonstrates the role of interface classes in defining the relationship between the main control class and the sub-control classes.
[0207] The extended base class SubControllerBaseClass ensures that the subcontroller classes implement the interface defined by the interface class IMainController.
[0208] The registration information includes the interface types implemented by the sub-controller classes, which facilitates type checking and interface calls by the main controller class.
[0209] The main control class calls the functionality of the sub-control class through interface classes and extended base classes.
[0210] Through these connections, the SCR model achieves decoupling and dynamic association between the main control class and the sub-control classes.
[0211] In the SCR model, the registration process and content of sub-controller classes can be adjusted according to specific implementation methods and requirements. For example, the registration process, registration content, and possible information are illustrated below:
[0212] I. The registration process is as follows:
[0213] 1. Sub-controller class creation:
[0214] The subcontroller class inherits from and extends the base class SubControllerBaseClass, and implements the interfaces defined by it.
[0215] The sub-controller class completes its own initialization and functionality implementation.
[0216] 2. Registration Information Preparation:
[0217] The sub-controller class prepares the information required for registration, such as:
[0218] A unique identifier (ID or name) for the sub-control class.
[0219] An instance or class type of the sub-controller class.
[0220] Information about the interfaces implemented by the sub-controller classes.
[0221] Configuration information for sub-control classes (optional).
[0222] 3. Registry access:
[0223] The sub-controller class accesses the sub-controller class's registry through the registration interface provided by the main controller class or the registry management class.
[0224] 4. Add registration information:
[0225] The sub-control class adds the prepared registration information to the registry.
[0226] The registry typically stores information in the form of key-value pairs, for example:
[0227] Key: A unique identifier for the subclass control.
[0228] Value: An instance or class type of the subclass.
[0229] 5. Registration complete:
[0230] When the registry is updated, the main control class can obtain information about the sub-control classes through the registry.
[0231] II. Registration Details:
[0232] The registration details can be expanded according to actual needs. Here are some common registration details:
[0233] Sub-control class identifier:
[0234] Used to uniquely identify sub-controller classes, making it easier for the main controller class to find and manage them.
[0235] Sub-control class instance or class type:
[0236] Instances of the sub-controller class can be used directly for invocation, while class types can be used to dynamically create instances.
[0237] Sub-controller class interface type information:
[0238] Describes the interfaces implemented by the sub-controller classes, making it easier for the main controller class to perform type checking and interface calls.
[0239] Sub-control class configuration information:
[0240] It contains initialization parameters or configuration data for sub-controller classes, used for dynamically configuring sub-controller classes.
[0241] Sub-controller priority:
[0242] When multiple subclasses implement the same function, priority can determine the order in which they are called.
[0243] III. Implementation Method:
[0244] Use a Map or Dictionary:
[0245] The registry can be implemented using a Map or Dictionary data structure to store sub-control class information in the form of key-value pairs.
[0246] Use a dedicated registration management class:
[0247] You can create a dedicated registry management class to encapsulate the access and management logic of the registry.
[0248] Using a dependency injection container:
[0249] If the project uses a dependency injection framework, a dependency injection container can be used to manage the registration and dependencies of sub-controller classes.
[0250] Example code (pseudocode):
[0251]
[0252]
[0253] In this way, the SCR model enables dynamic registration and discovery of sub-control classes, improving the system's flexibility and scalability.
[0254] In an optional embodiment of the present invention, it further includes:
[0255] Determine the target sub-control class;
[0256] The main control class is controlled to read the registry of the sub-control class to obtain the target interface class of the target sub-control class;
[0257] The target sub-control class is called through the target interface class.
[0258] This invention enables the determination of a target sub-control class, allowing the main control class to determine the sub-control class to be invoked based on business logic or user interaction. This achieves dynamic selection and invocation of sub-control classes by the main control class, improving system flexibility. It also allows the main control class to select different sub-control classes based on different scenarios, enabling dynamic combination of functions.
[0259] In this embodiment of the invention, the main control class can also be controlled to read the registry of the sub-control class to obtain the target interface class of the target sub-control class;
[0260] For example, the main control class retrieves information about the target sub-control class from the registry using its unique identifier (ID or name) to obtain the interface types implemented by the target sub-control class. Through the registry, the main control class can dynamically obtain the interface information of the sub-control class without hard-coding dependencies. Using the interface type information, the main control class can perform type checking to ensure safe invocation of the sub-control class.
[0261] In this embodiment of the invention, the target sub-control class can be called through the target interface class. This allows the main control class to call the functionality of the target sub-control class through the target interface class, and the main control class can pass parameters to the sub-control class as needed. This achieves decoupling between the main control class and the sub-control class, eliminating the need for the main control class to be concerned with the specific implementation of the sub-control class. Interface calls ensure the independence between modules and improve code maintainability and scalability.
[0262] In this embodiment of the invention, by determining a target sub-control class; controlling the main control class to read the sub-control class's registry to obtain the target interface class of the target sub-control class; and calling the target sub-control class through the target interface class, the SCR model realizes dynamic calling of the sub-control class by the main control class, bringing the following beneficial effects:
[0263] Dynamic invocation:
[0264] The main control class can dynamically select and call sub-control classes as needed, improving the system's flexibility.
[0265] Module decoupling:
[0266] The main control class calls the sub-control class through an interface, which reduces the dependencies between modules.
[0267] Type safety:
[0268] By using the interface type information, the main control class can perform type checking to ensure safe invocation of sub-control classes.
[0269] Improve maintainability:
[0270] The independence between modules makes the code easier to maintain and test.
[0271] Improve development efficiency:
[0272] Each module can be developed independently, which improves development efficiency.
[0273] For example, in order to invoke the target sub-control class required by the user by reading the contents of the sub-control class registry that has already been entered, the main control class needs to perform the following steps:
[0274] 1. Read the registry:
[0275] The main control class first needs to access the registry of the child control class.
[0276] There are many ways to implement the registry, including:
[0277] A Map or Dictionary data structure.
[0278] A dedicated registration management class.
[0279] Dependency injection container.
[0280] The main control class can retrieve information about all sub-control classes or a specific sub-control class from the registry as needed.
[0281] 2. Obtain sub-controller information:
[0282] Retrieve instances of subcontroller classes or information related to subcontroller classes from the registry.
[0283] Subcontrol class information in the registry may include:
[0284] A unique identifier (ID or name) for the sub-control class.
[0285] An instance or class type of the sub-controller class.
[0286] The interface type implemented by the sub-controller class.
[0287] Configuration information for sub-controller classes.
[0288] 3. Type checking and interface conversion:
[0289] The main control class checks whether the sub-control classes have implemented the required interfaces, as needed.
[0290] If the subcontroller class implements the required interface, then the instance of the subcontroller class is cast to the corresponding interface type.
[0291] Through the interface type, the main control class can call the functions of the sub-control class.
[0292] 4. Calling sub-controller functions:
[0293] The main control class calls the functionality of the sub-control class through the interface type.
[0294] The main control class can pass parameters to the sub-control classes as needed.
[0295] The sub-controller class performs the corresponding function and returns the result to the main controller class.
[0296] In an optional embodiment of this invention, when a new sub-control class inheriting from the extended base class is obtained, the interface type information of the new sub-control class is determined based on the interface class;
[0297] Add the newly added sub-control class and its interface type information to the sub-control class registry.
[0298] In a specific implementation, when a new sub-control class inheriting from the extended base class is obtained, the interface type information of the new sub-control class can be determined based on the interface class.
[0299] Purpose:
[0300] Specify the interface types implemented by the newly added sub-controller classes. These interface types define the ability of the newly added sub-controller classes to interact with the main controller class.
[0301] This provides interface type information for subsequent registration, enabling the main control class to perform type checking and interface calls.
[0302] Beneficial effects:
[0303] This ensures that newly added sub-controller classes conform to the interface specifications defined by the main controller class, guaranteeing compatibility between modules.
[0304] It provides a unified interface calling method for the main control class, reducing the coupling between the main control class and the sub-control classes.
[0305] By using interface type information, the main control class can dynamically check at runtime whether newly added sub-control classes implement the required interfaces.
[0306] In this embodiment of the invention, the newly added sub-control class and the interface type information of the newly added sub-control class can also be added to the sub-control class registry.
[0307] Purpose:
[0308] Register the newly added sub-control class and its interface type information to the registry.
[0309] Establish the association between the main control class and the newly added sub-control class, and clarify the interface implemented by the newly added sub-control class.
[0310] Beneficial effects:
[0311] The main control class can dynamically discover and manage newly added sub-control classes through the registry, and learn about their interface information.
[0312] Dynamic registration and discovery of sub-controller classes have been implemented, improving the system's flexibility.
[0313] By adding interface type information to the registry, the main control class can more accurately call newly added sub-control classes, avoiding type conversion errors.
[0314] This allows the main control class to perform type checking based on the interface type when calling the sub-control class, thus avoiding calling errors.
[0315] Through the above steps, the SCR model achieves dynamic registration and discovery of newly added sub-control classes by using the registry and interface type information, and clarifies the interfaces implemented by the newly added sub-control classes, bringing the following beneficial effects:
[0316] Dynamic expansion:
[0317] Adding a new sub-control class only requires registering it in the registry; there is no need to modify the main control class, thus enabling dynamic system expansion.
[0318] Module decoupling:
[0319] The functional modules communicate with each other through interfaces instead of direct calls, which reduces the dependencies between modules.
[0320] Improve maintainability:
[0321] The independence between modules makes the code easier to maintain and test.
[0322] Improve development efficiency:
[0323] Each module can be developed independently, which improves development efficiency.
[0324] Type safety:
[0325] By using the interface type information of the sub-controller class, the main controller class can call the sub-controller class more accurately, avoiding type conversion errors.
[0326] In this embodiment of the invention, when a new sub-control class inheriting from the extended base class is obtained, the interface type information of the new sub-control class is determined based on the interface class; the new sub-control class and its interface type information are then added to the sub-control class registry. Registering the new sub-control class to the sub-control class registry achieves decoupling and dynamic expansion between modules while ensuring type safety.
[0327] In an optional embodiment of the present invention, it further includes:
[0328] The newly added sub-control class is identified as the newly added main control class, and the new external capability type of the newly added main control class is determined.
[0329] Construct a new interface class based on the newly added external capability type;
[0330] Determine the subclasses of the newly added main control class, and the general function types of the subclasses of the main control class;
[0331] Based on the aforementioned general functions, a new extended base class is constructed;
[0332] Based on the newly added interface class and the newly added extended base class, a new association relationship is constructed between the newly added main control class and the newly added sub-control class, and an application is generated based on the association relationship and the newly added association relationship.
[0333] Optionally, the step of constructing the new association between the new main control class and the new grandchild control class based on the new interface class and the new extended base class includes:
[0334] Based on the newly added interface class, determine the interface type information of the grandchild control class of the grandchild control class;
[0335] Construct a new initial registry for the aforementioned grandchild control class;
[0336] The grandchild control class that inherits from the newly added extended base class and the interface type information of the grandchild control class are added to the newly added initial registry to generate the grandchild control class registry; the grandchild control class registry is used to express the association relationship between the newly added main control class and the grandchild control class.
[0337] In a specific implementation, the embodiments of the present invention can determine the newly added sub-control class as the newly added main control class, and determine the newly added external capability type of the newly added main control class;
[0338] Purpose:
[0339] Promote the previously registered sub-controller class to the new main controller class so that it can manage its sub-grandchild controller classes.
[0340] Determine the capabilities that the new main control class will provide to the outside world, in preparation for building new interface classes.
[0341] Beneficial effects:
[0342] It implements the recursive application of the SCR model, which can decouple tree structures of arbitrary depth.
[0343] This enables sub-controller classes to manage their subordinate controller classes, improving the system's flexibility and scalability.
[0344] In this embodiment of the invention, a new interface class can also be constructed based on the newly added external capability type;
[0345] Purpose:
[0346] Define the capability interface that the new main control class provides to its subclass control classes.
[0347] Standardize the interaction between the new main controller class and its subclasses.
[0348] Beneficial effects:
[0349] This achieves decoupling between the new main controller class and its grandchild controller classes.
[0350] This ensures that the grandchild controller class can interact with the new main controller class in a unified manner.
[0351] Determine the subclasses of the newly added main control class, and the general function types of the subclasses of the main control class;
[0352] Purpose:
[0353] Determine the subclasses that the new main control class needs to manage.
[0354] Determine the common functionalities that the grandchild control class needs to implement, in preparation for building a new extended base class.
[0355] Beneficial effects:
[0356] This implements the management of its subclasses by a new main controller class.
[0357] The behavior of the grandchild control class has been standardized, making it easier for the main control class to call it uniformly.
[0358] Based on the aforementioned general functions, a new extended base class is constructed;
[0359] Purpose:
[0360] Define the common functions and specifications that the grandchild control class must implement.
[0361] Provide a unified parent class for the grandchild control class.
[0362] Beneficial effects:
[0363] This ensures that all grandchild control classes follow the same standard, making it easier for the new main control class to manage and call them.
[0364] It improves code reusability.
[0365] Based on the newly added interface class and the newly added extended base class, a new association relationship is constructed between the newly added main control class and the newly added sub-control class, and an application is generated based on the association relationship and the newly added association relationship.
[0366] Purpose:
[0367] Establish a new association between the main control class and its subclasses.
[0368] Integrate all hierarchical relationships into the application.
[0369] Beneficial effects:
[0370] This achieves nested decoupling of the entire tree structure.
[0371] This ensures the correct operation of the application.
[0372] Optionally, the step of constructing the new association between the new main control class and the new grandchild control class based on the new interface class and the new extended base class includes:
[0373] Based on the newly added interface class, determine the interface type information of the grandchild control class of the grandchild control class;
[0374] Purpose:
[0375] Define the interface types that the grandchild controller class needs to implement. These interface types define the ability of the grandchild controller class to interact with the newly added main controller class.
[0376] Beneficial effects:
[0377] This ensures that the subclasses of the main control class conform to the interface specifications defined in the newly added main control class, guaranteeing compatibility between modules.
[0378] Construct a new initial registry for the aforementioned grandchild control class;
[0379] Purpose:
[0380] Create a container to store information about the grandchild control class.
[0381] Beneficial effects:
[0382] This provides a unified entry point for managing subclasses of the newly added main control class.
[0383] The grandchild control class that inherits from the newly added extended base class and the interface type information of the grandchild control class are added to the newly added initial registry to generate the grandchild control class registry; the grandchild control class registry is used to express the association relationship between the newly added main control class and the grandchild control class.
[0384] Purpose:
[0385] Register all grandchild control classes that inherit from the newly added extended base class and their interface type information to the registry.
[0386] Beneficial effects:
[0387] The newly added main control class can dynamically discover and manage sub-control classes through the registry, and understand their interface information.
[0388] Through the above steps, the nested implementation of the SCR model can effectively decouple the logical relationships of the tree structure, improving the system's flexibility, scalability, and maintainability.
[0389] refer to Figure 4 , Figure 4 This is a structural relationship diagram of a main control class, a sub-control class, and a grandchild control class provided in an embodiment of the present invention;
[0390] Figure 4This diagram details the nested implementation of the SCR (Sub Composite Registration) model, used to decouple the logical relationships within a tree-like structure. The following is a detailed explanation of the diagram's content:
[0391] The overall structure includes a two-level nested SCR triangular relationship model.
[0392] First layer:
[0393] MainController serves as the main controller class, and manages multiple SubController sub-controller classes through the SubControllerRegistration registry.
[0394] The IMainController interface class defines the capabilities that MainController provides to SubControllers...
[0395] The SubControllerBaseClass extended base class defines the common functionalities and specifications that SubController... must implement.
[0396] Second layer:
[0397] The SubController (which is a sub-controller class in the first level) is promoted to a new main controller class in the second level, and multiple GrandsonControllers are managed through the SubControllerRegistratio registry.
[0398] The IController interface class defines the capabilities that SubController... provides to GrandsonController....
[0399] The GrandsonControllerBaseClass extended base class defines the common functionalities and specifications that GrandsonController... must implement.
[0400] Key components:
[0401] MainController / SubController...:
[0402] The main control class is responsible for managing its subordinate sub-control classes.
[0403] The system dynamically discovers and invokes the functions of sub-control classes through the registry.
[0404] IMainController / IController:
[0405] An interface class defines the capabilities that the main control class provides to the child control classes.
[0406] This achieves decoupling between the main control class and the sub-control classes.
[0407] SubControllerBaseClass / GrandsonControllerBaseClass:
[0408] Extend the base class to define the common functionalities and specifications that child control classes must implement.
[0409] It improves code reusability and maintainability.
[0410] SubControllerRegistration:
[0411] The subcontroller registry is used to store and manage information about subcontrollers.
[0412] Dynamic registration and discovery of sub-controller classes have been implemented.
[0413] Relationships and interactions:
[0414] register:
[0415] The sub-control class is registered to the main control class via the registry.
[0416] The main control class obtains information about the sub-control classes through the registry.
[0417] Call:
[0418] The main control class calls the functionality of the sub-control class through the interface class.
[0419] Sub-controller classes implement common functionalities by extending the base class.
[0420] Nesting:
[0421] A subclass can act as a new main class, managing its subclasses.
[0422] Nesting allows for the decoupling of tree structures at any depth.
[0423] By recursively applying the triangular relationship model of SCR, complex tree structures can be decomposed into multiple simple triangular relationship models, thereby achieving complete decoupling between modules and improving the system's flexibility, scalability, and maintainability.
[0424] In an optional embodiment of the present invention, it further includes:
[0425] Identify the target subclass control class;
[0426] The newly added main control class is controlled to read the registry of the grandchild control class to obtain the newly added target interface class of the target grandchild control class;
[0427] The target grandchild control class is called through the newly added target interface class.
[0428] The embodiments of the present invention can determine the target grandchild control class;
[0429] Purpose:
[0430] The newly added main control class determines the sub-control classes that need to be called based on business logic or user interaction.
[0431] This could be based on user input, system status, or other triggering conditions.
[0432] Beneficial effects:
[0433] The system enables dynamic selection and invocation of subclasses by the newly added main control class, improving the system's flexibility.
[0434] The system allows the addition of a main control class to select different subclasses based on different scenarios, thus enabling dynamic combination of functions.
[0435] In this embodiment of the invention, the newly added main control class can also be controlled to read the registry of the grandchild control class to obtain the newly added target interface class of the target grandchild control class;
[0436] Purpose:
[0437] The newly added main control class retrieves information about the target sub-control class from the registry using the sub-control class's unique identifier (ID or name).
[0438] Retrieve the interface type implemented by the target grandchild control class from the registry.
[0439] Beneficial effects:
[0440] By using the registry, a new main control class can dynamically obtain the interface information of its subclasses without hard-coding dependencies.
[0441] By using the interface type information, the newly added main control class can perform type checks to ensure safe invocation of the sub-control class.
[0442] In this embodiment of the invention, the target grandchild control class can also be called through the newly added target interface class.
[0443] Purpose:
[0444] The newly added main control class calls the functionality of the target sub-control class through the target interface class.
[0445] The newly added main control class can pass parameters to the sub-control classes as needed.
[0446] Beneficial effects:
[0447] This achieves decoupling between the newly added main control class and the sub-control classes, so that the newly added main control class does not need to care about the specific implementation of the sub-control classes.
[0448] By using API calls, the independence between modules is ensured, and the maintainability and scalability of the code are improved.
[0449] Through the above steps, the nested implementation of the SCR model enables dynamic invocation of subclasses by the newly added main control class, bringing the following beneficial effects:
[0450] Dynamic invocation:
[0451] The newly added main control class can dynamically select and call sub-control classes as needed, improving the system's flexibility.
[0452] Module decoupling:
[0453] The newly added main control class calls the sub-control class through an interface, reducing the dependencies between modules.
[0454] Type safety:
[0455] By using the interface type information, the newly added main control class can perform type checks to ensure safe invocation of the sub-control class.
[0456] Improve maintainability:
[0457] The independence between modules makes the code easier to maintain and test.
[0458] Improve development efficiency:
[0459] Each module can be developed independently, which improves development efficiency.
[0460] To enable those skilled in the art to better understand the embodiments of the present invention, an example is used below to illustrate the embodiments of the present invention.
[0461] 1. Requirements Analysis and Module Division:
[0462] First, it is necessary to conduct an in-depth analysis of the application's requirements and clarify the responsibilities and interaction methods of each functional module.
[0463] Based on the cohesion and coupling of functional modules, the main controller and sub-controllers should be reasonably divided.
[0464] Identify which modules need to be the main controller, which modules need to be the sub-controllers, and the hierarchical relationship between them.
[0465] 2. Define the triangular relationship model:
[0466] Main interface class definition:
[0467] Based on the functional requirements of the main controller, define clear interface classes that specify the capabilities that the main controller provides to the outside world (such as adding child controllers, obtaining resources, etc.).
[0468] Ensure the universality and stability of the interface so that sub-controllers can be easily implemented and invoked.
[0469] Extended base class definition:
[0470] Define an extended base class that provides basic functionality and initialization methods for child controllers to inherit.
[0471] The base class should contain common methods needed to interact with the main controller so that child controllers can easily register and communicate.
[0472] Main controller class (main body) implementation:
[0473] Implement the main controller to manage core logic and resources, and use interface classes to enable interaction between sub-controllers.
[0474] The main controller should be kept simple and should not directly depend on specific sub-controller implementations.
[0475] 3. Implement the SCR nesting mechanism:
[0476] Sub-controller implementation:
[0477] The child controller inherits from and extends the base class, implements the main interface class, and completes its own functional logic.
[0478] Sub-controllers are dynamically registered to their corresponding main controllers via the SubCompositeRegistration.
[0479] Registry implementation:
[0480] Implement a registry to manage the registration and binding relationships of sub-controllers.
[0481] The registry should support multi-level nesting to enable complex module organization structures.
[0482] Main controller extension:
[0483] In the main controller, sub-controllers are dynamically added and managed using the registry.
[0484] The main controller interacts with the sub-controllers through interfaces to combine and extend functions.
[0485] 4. Module integration and testing:
[0486] Module integration:
[0487] Integrate the various modules together to ensure that the interactions between the modules meet expectations.
[0488] By configuring the registry, the combination of modules can be dynamically adjusted to verify the system's flexibility.
[0489] Unit testing and integration testing:
[0490] Perform unit tests on each module to ensure that it functions correctly.
[0491] Perform integration testing to verify that the modules work together correctly.
[0492] System testing:
[0493] Conduct comprehensive system testing to ensure that the application's functionality and performance meet the requirements.
[0494] 5. Optimization and Maintenance:
[0495] Performance optimization:
[0496] Analyze the application's performance bottlenecks and optimize module implementation and interaction methods.
[0497] Improve application response speed and resource utilization through caching, asynchronous processing, and other methods.
[0498] Code maintenance:
[0499] Keep the code clear and concise, and write detailed documentation to facilitate future maintenance and expansion.
[0500] Follow design principles to reduce coupling between modules and improve code maintainability.
[0501] Continuous iteration:
[0502] We continuously iterate and optimize the application based on user feedback and changing needs.
[0503] The dynamic registration mechanism makes it easy to add new sub-controllers without requiring large-scale changes to existing code.
[0504] The advantages of the above method compared to related technologies are shown in Table 1.
[0505] Table 1:
[0506]
[0507]
[0508] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0509] Reference Figure 5 The diagram illustrates a structural block diagram of an application generation device provided in an embodiment of the present invention, which may specifically include the following modules:
[0510] The main control class determination module 501 is used to determine the main control class and the external capability type of the main control class;
[0511] Interface class construction module 502 is used to construct interface classes based on the external capability type;
[0512] The sub-control class determination module 503 is used to determine the sub-control class for the main control class, and the general function type of the sub-control class;
[0513] Extended base class construction module 504 is used to construct an extended base class based on the general functions;
[0514] The association construction module 505 is used to construct the association between the main control class and the sub-control class based on the interface class and the extended base class, and to generate an application based on the association.
[0515] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0516] In addition, embodiments of the present invention also provide an electronic device, such as... Figure 6 As shown, it includes a processor 601, a communication interface 602, a memory 603, and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.
[0517] Memory 603 is used to store computer programs;
[0518] When the processor 601 executes the program stored in the memory 603, it implements any of the application generation methods described in the above embodiments:
[0519] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0520] The communication interface is used for communication between the aforementioned terminal and other devices.
[0521] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0522] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0523] like Figure 7 As shown, in another embodiment of the present invention, a computer-readable storage medium 701 is also provided, which stores instructions that, when run on a computer, cause the computer to execute the application generation method described in the above embodiments.
[0524] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.
[0525] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0526] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0527] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0528] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0529] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0530] 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, ROM, RAM, magnetic disks, or optical disks.
[0531] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. An application generation method, characterized in that, include: Determine the main control class and the external capability types of the main control class; The external capability type refers to the functions and services provided by the main control class to the sub-control class; An interface class is constructed based on the aforementioned external capability type; the interface class defines the capability interface provided by the main control class to the sub-control class, and is used to define the methods and attributes that the main control class should implement; Determine the sub-control classes for the main control class, and the general function type of the sub-control classes; the general function type is the general specification that the sub-control classes need to follow. An extended base class is constructed based on the aforementioned general functions; the extended base class is used to define the interfaces that the sub-control classes must implement; The association between the main control class and the sub-control class is constructed based on the interface class and the extended base class, and the application is generated based on the association. The step of constructing the association between the main control class and the sub-control class based on the interface class and the extended base class includes: The sub-control class interface type information of the sub-control class is determined based on the interface class; Construct an initial registry for the sub-control class; The sub-control class inherited from the extended base class and the interface type information of the sub-control class are added to the initial registry to generate the sub-control class registry; the sub-control class registry is used to express the association relationship between the main control class and the sub-control class; the registration content of the sub-control class registry includes the sub-control class identifier, sub-control class instance or class type, sub-control class configuration information and sub-control class priority.
2. The method according to claim 1, characterized in that, Also includes: Determine the target sub-control class; The main control class is controlled to read the registry of the sub-control class to obtain the target interface class of the target sub-control class; The target sub-control class is called through the target interface class.
3. The method according to claim 2, characterized in that, Also includes: When a new sub-control class that inherits from the extended base class is obtained, the interface type information of the new sub-control class is determined based on the interface class. Add the newly added sub-control class and its interface type information to the sub-control class registry.
4. The method according to claim 3, characterized in that, Also includes: The newly added sub-control class is identified as the newly added main control class, and the new external capability type of the newly added main control class is determined. Construct a new interface class based on the newly added external capability type; Determine the subclasses of the newly added main control class, and the general function types of the subclasses of the main control class; Based on the aforementioned general functions, a new extended base class is constructed; Based on the newly added interface class and the newly added extended base class, a new association relationship is constructed between the newly added main control class and the newly added sub-control class, and an application is generated based on the association relationship and the newly added association relationship.
5. The method according to claim 4, characterized in that, The step of constructing the new association relationship between the new main control class and the new grandchild control class based on the new interface class and the new extended base class includes: Based on the newly added interface class, determine the interface type information of the grandchild control class of the grandchild control class; Construct a new initial registry for the aforementioned grandchild control class; The grandchild control class that inherits from the newly added extended base class and the interface type information of the grandchild control class are added to the newly added initial registry to generate the grandchild control class registry; the grandchild control class registry is used to express the association relationship between the newly added main control class and the grandchild control class.
6. The method according to claim 5, characterized in that, Also includes: Identify the target subclass control class; The newly added main control class is controlled to read the registry of the grandchild control class to obtain the newly added target interface class of the target grandchild control class; The target grandchild control class is called through the newly added target interface class.
7. An application generation apparatus, characterized in that, include: The main control class determination module is used to determine the main control class and the external capability type of the main control class; The external capability type refers to the functions and services provided by the main control class to the sub-control class; An interface class construction module is used to construct interface classes based on the external capability type; the interface class defines the capability interface provided by the main control class to the sub-control class, and is used to define the methods and attributes that the main control class should implement; The sub-control class determination module is used to determine the sub-control classes for the main control class, and the general function type of the sub-control classes; the general function type is the general specification that the sub-control classes need to follow. An extended base class construction module is used to construct an extended base class based on the general functionality; the extended base class is used to define the interfaces that the sub-control classes must implement; The association relationship construction module is used to construct the association relationship between the main control class and the sub-control class based on the interface class and the extended base class, and generate an application based on the association relationship; The association construction module is further configured to: determine the sub-control class interface type information of the sub-control class based on the interface class; construct an initial registry for the sub-control class; add the sub-control class inherited from the extended base class and the sub-control class interface type information to the initial registry to generate a sub-control class registry; the sub-control class registry is used to express the association relationship between the main control class and the sub-control class; the registration content of the sub-control class registry includes the sub-control class identifier, sub-control class instance or class type, sub-control class configuration information, and sub-control class priority.
8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; The memory is used to store computer programs; When the processor executes a program stored in the memory, it implements the method as described in any one of claims 1-6.
9. A computer-readable storage medium having instructions stored thereon that, when executed by one or more processors, cause the processors to perform the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Management system based on plug-in access device
CN102360292A