Method, apparatus, system, electronic device and storage medium for installing sub-function block
By splitting and releasing independent sub-functional blocks from functional blocks, the problem of resource waste and risk caused by redundant modules in software development is solved, and efficient code reuse and risk control are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SIEMENS (CHINA) CO LTD
- Filing Date
- 2024-12-31
- Publication Date
- 2026-06-30
AI Technical Summary
In software development, redundant functional modules exist in functional blocks, leading to resource waste and unpredictable risks, and increasing project development costs.
Identify independently executable sub-functional blocks from the functional blocks, split their code, build a general template based on the constraints of the R&D foundation, set input and output interfaces, and publish the code as a package to the package manager, which can then select and install it into the development project through a graphical user interface.
It effectively avoids the reuse of redundant code, saves system resources, reduces risks, and improves development efficiency and code quality.
Smart Images

Figure CN122308822A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software development technology, and in particular to methods, apparatus, systems, electronic devices, and storage media for installing sub-functional blocks. Background Technology
[0002] In software development, a functional block typically refers to a group of logically related pieces of code that work together to perform a specific function or task. Depending on the complexity of the software architecture and design, a functional block can contain functions, methods, classes, modules, or components, etc. Due to their independence, functional blocks can be reused in different parts of different projects or systems, reducing repetitive code writing.
[0003] However, when using function blocks in project engineering, there are often many redundant functional modules within these blocks that are not related to the project's requirements. These redundant functional modules not only waste resources but also pose unpredictable risks (such as vulnerability risks or infringement risks). In addition, redundant functional modules may also increase project development costs. Summary of the Invention
[0004] The present invention provides a method, apparatus, system, electronic device, and storage medium for installing sub-functional blocks.
[0005] A method for installing sub-functional blocks includes:
[0006] Identify independently executable sub-functional blocks from the functional blocks;
[0007] The code of the sub-functional blocks is split from the code of the functional block;
[0008] The code of the aforementioned sub-functional blocks is published to the package manager in the form of a package;
[0009] In response to a triggering operation, determine the packages to be installed into the development project;
[0010] Obtain the package to be installed into the development project from the package manager;
[0011] Install the package to be installed into the development project.
[0012] Therefore, reusing sub-functional blocks that do not contain redundant code from functional blocks can save system resources and prevent many risks.
[0013] In one implementation, splitting the code of the sub-functional block from the code of the functional block includes:
[0014] Determine the input parameters, output parameters, and business logic of the sub-functional block;
[0015] Obtain a general template suitable for carrying the code, wherein the general template inherits the constraints of the development foundation of the development project;
[0016] Write the business logic code into the general template;
[0017] Based on the input parameters of the sub-functional blocks, the input interface of the general template is set;
[0018] Based on the output parameters of the sub-functional blocks, the output interface of the general template is set.
[0019] Therefore, the code of sub-functional blocks is split based on the constraints of the R&D foundation of the development project, making it easier for the development project to use in the future.
[0020] In one implementation, determining the input and output parameters of the sub-functional block includes:
[0021] Based on the data flow analysis results, event flow analysis results, or function flow analysis results of the sub-functional blocks, determine the dependencies of the sub-functional blocks;
[0022] Based on the dependencies, the input parameters and output parameters of the sub-functional block are determined; wherein the input parameters represent the sub-functional block's dependencies on anything outside the sub-functional block, and the output parameters represent the dependencies of anything outside the sub-functional block on the sub-functional block.
[0023] As can be seen, the interface of the sub-functional blocks can be easily implemented based on the dependency relationship of the sub-functional blocks.
[0024] In one implementation, the step of publishing the code of the sub-functional block to the package manager in the form of a package includes:
[0025] Based on the build command, the general template is built into a package suitable for publishing to the package manager;
[0026] Based on the publish command, the package suitable for publication to the package manager is published to the package manager.
[0027] Therefore, the code of sub-functional blocks can be easily published to the package manager in the form of packages, making it convenient for various development projects to use in the future.
[0028] In one implementation, determining the package to be installed into the development project in response to a triggering operation includes:
[0029] Display an icon for each package in the package manager in the graphical user interface (GUI);
[0030] In response to the triggering operation triggered in the graphical user interface, at least one icon is selected from the graphical user interface;
[0031] The package to be installed into the development project is determined by identifying at least one package corresponding to the at least one icon.
[0032] Therefore, based on the trigger operation initiated in the graphical user interface, it is convenient to select the package to be installed.
[0033] In one implementation, determining independently executable sub-functional blocks from the functional blocks includes:
[0034] Determine the business logic of the functional block;
[0035] Apply the Single Responsibility Principle to identify the sub-business logics within the aforementioned business logic that each bear different responsibilities;
[0036] The sub-business logic is defined as the independently executable sub-functional block.
[0037] As can be seen, defining sub-functional blocks based on the single responsibility principle can separate sub-functional blocks with a single function, thereby preventing redundant code in the sub-functional blocks.
[0038] An apparatus for mounting sub-functional blocks, comprising:
[0039] The first determining module is used to determine independently executable sub-functional blocks from the functional blocks;
[0040] A splitting module is used to split the code of the sub-functional blocks from the code of the functional block;
[0041] The publishing module is used to publish the code of the sub-functional blocks to the package manager in the form of packages;
[0042] The second determination module is used to determine the package to be installed into the development project in response to the trigger operation;
[0043] The acquisition module is used to acquire the package to be installed into the development project from the package manager;
[0044] An installation module is used to install the package to be installed into the development project.
[0045] Therefore, reusing sub-functional blocks that do not contain redundant code from functional blocks can save system resources and prevent many risks.
[0046] In one implementation, the splitting module is used to determine the input parameters, output parameters, and business logic of the sub-functional block; obtain a general template suitable for carrying code, the general template inheriting the constraints of the development foundation of the development project; write the code of the business logic into the general template; set the input interface of the general template based on the input parameters of the sub-functional block; and set the output interface of the general template based on the output parameters of the sub-functional block.
[0047] Therefore, the code of sub-functional blocks is split based on the constraints of the R&D foundation of the development project, making it easier for the development project to use in the future.
[0048] In one implementation, the splitting module is configured to determine the dependencies of the sub-functional blocks based on the data flow analysis results, event flow analysis results, or function flow analysis results of the sub-functional blocks; and to determine the input parameters and output parameters of the sub-functional blocks based on the dependencies; wherein the input parameters characterize the dependencies of the sub-functional blocks on anything outside the sub-functional blocks, and the output parameters characterize the dependencies of anything outside the sub-functional blocks on the sub-functional blocks.
[0049] As can be seen, the interface of the sub-functional blocks can be easily implemented based on the dependency relationship of the sub-functional blocks.
[0050] A system for installing sub-functional blocks includes a distribution device, a package manager, and a development device, wherein:
[0051] The publishing device is configured to determine independently executable sub-functional blocks from the functional blocks; split the code of the sub-functional blocks from the code of the functional blocks; and publish the code of the sub-functional blocks to the package manager in the form of a package.
[0052] The package manager is used to manage the packages;
[0053] The development apparatus is configured to, in response to a trigger operation, determine a package to be installed into a development project; obtain the package to be installed into the development project from the package manager; and install the package to be installed into the development project.
[0054] In one implementation, the package manager is located in the cloud;
[0055] The package manager is configured to perform at least one of the following:
[0056] Package installation management; package version management; package dependency update management; global and local package management; package release management.
[0057] An electronic device, comprising:
[0058] processor;
[0059] Memory for storing the executable instructions of the processor;
[0060] The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the method of installing sub-functional blocks as described above.
[0061] A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the method of installing sub-functional blocks as described above.
[0062] A computer program product includes a computer program that, when executed by a processor, implements the method of installing sub-functional blocks as described above. Attached Figure Description
[0063] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which will make the above and other features and advantages of the present invention more apparent to those skilled in the art. In the drawings:
[0064] Figure 1 This is an exemplary flowchart of a method for installing sub-functional blocks according to an embodiment of the present invention.
[0065] Figure 2 This is an exemplary structural diagram of a system for installing sub-functional blocks according to an embodiment of the present invention.
[0066] Figure 3 This is an exemplary schematic diagram illustrating the generation of Node Package Manager (NPM) packages according to an embodiment of the present invention.
[0067] Figure 4 This is a schematic diagram illustrating an exemplary process of installing sub-functional blocks according to an embodiment of the present invention.
[0068] Figure 5 This is an exemplary structural diagram of an apparatus for mounting sub-functional blocks according to an embodiment of the present invention.
[0069] Figure 6 This is an exemplary structural diagram of an electronic device according to an embodiment of the present invention.
[0070] The accompanying figure is labeled as follows:
[0071]
[0072]
[0073] Detailed Implementation
[0074] To make the objectives, technical solutions, and advantages of this invention clearer, the following embodiments are provided to further illustrate the invention in detail. The nouns and pronouns referring to "person" in this patent application are not limited to specific genders.
[0075] For the sake of brevity and intuitiveness, the following description uses several representative embodiments to illustrate the solution of the present invention. Numerous details in the embodiments are only used to aid in understanding the solution of the present invention. However, it is obvious that the technical solution of the present invention can be implemented without being limited to these details. To avoid unnecessarily obscuring the solution of the present invention, some embodiments are not described in detail, but only a framework is given. In the following text, "comprising" means "including but not limited to," and "according to..." means "at least according to..., but not limited to only according to...". Due to Chinese language habits, unless the quantity of a component is specifically indicated below, it means that the component can be one or more, or can be understood as at least one.
[0076] In software development, a development infrastructure typically refers to the set of infrastructure and tools that build and support software systems or applications. It provides the necessary hardware, software, and services to support the development, deployment, operation, and management of applications. A robust development infrastructure provides a stable operating environment, supports rapid application iteration and innovation, and possesses good scalability and maintainability, thus providing strong support for the company's business development.
[0077] Typically, a development platform can include: (1) technical frameworks and programming languages; (2) development tools and platforms, such as integrated development environments (IDEs), build tools, version control systems, etc., which help developers write and maintain code more efficiently; (3) database and storage solutions, where the development platform needs to provide database systems or other data storage solutions for application data persistence and management; (4) security guarantees, including authentication, access control, data encryption, and other mechanisms to protect the security of applications and data; (5) monitoring and log management tools, used to monitor the running status, performance indicators, and log information of applications in order to discover and resolve problems in a timely manner; (6) automation and deployment tools, which simplify the deployment and operation and maintenance process of applications and improve efficiency and reliability; and (7) common capability components, in a cloud-native environment, the development platform may include the extraction of unified common capability components, such as identity authentication, log management, and monitoring systems. These common components will be extracted and provided as platform services for various applications to call.
[0078] In software development based on a development platform, reusing functional blocks constrained by that platform to build software is a common practice. This helps improve development efficiency, reduce costs, and enhance software maintainability. Developers can obtain numerous types of functional blocks from various management platforms and effectively reuse them to build more robust, flexible, and maintainable software systems. This reuse not only accelerates development but also helps reduce errors and improve code quality.
[0079] However, when using function blocks in project engineering, there are often many redundant functional modules that are not related to the project's requirements. These redundant functional modules not only waste resources but also pose unpredictable risks (such as vulnerability risks or infringement risks). In addition, redundant functional modules may also increase project development costs.
[0080] For example, if a project requires a "menu" function, function block A containing the "menu" function can be reused. However, function block A may also contain redundant code such as "permissions" and "dictionary" functions that are not needed in the project. This redundant code not only wastes resources but may also pose unpredictable vulnerability risks and even intellectual property risks (for example, the "dictionary" function may be protected by intellectual property rights). In this case, directly reusing the function block containing the "menu" function carries corresponding risks and significant costs.
[0081] In this embodiment of the invention, independently executable sub-functional blocks are identified from the functional blocks, and the code of the sub-functional blocks is extracted from the code of the functional blocks. The code of the sub-functional blocks is then published to the package management platform. Subsequently, the sub-functional blocks without redundant code can be directly reused in the project, which can effectively overcome the above-mentioned defects.
[0082] The above disclosure details the technical defects existing in the relevant technology, the causes of these defects, and the analytical process for overcoming them. In fact, the understanding of these technical defects is not common knowledge in the field, but rather a novel discovery made by the applicant during their research. Furthermore, the tracing of the causes of these technical defects and the analytical process for overcoming them are also the results of the applicant's gradual analysis during the actual research process, and are not common knowledge in the field.
[0083] Figure 1 This is an exemplary flowchart of a method for installing sub-functional blocks according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0084] Step 101: Identify the independently executable sub-functional blocks from the functional blocks.
[0085] A functional block refers to a logically related group of code that work together to perform a specific function or task. Depending on the complexity of the software architecture and design, a functional block can contain functions, methods, classes, modules, or components, etc. For example, a functional block may include developed mathematical operation functional blocks, timer and counter functional blocks, PID controller functional blocks, communication protocol functional blocks, or real-time monitoring and diagnostic functional blocks, and so on.
[0086] Here, independently executable sub-functional blocks can be identified from functional blocks based on user-configured operations or automated instructions. When splitting sub-functional blocks, the following principles can be considered: (1) Single Responsibility Principle: Each sub-functional block should have one and only one clearly defined function, which is the basis of modular design. (2) Reusability: Sub-functional blocks may also be used in other parts of the software, thereby improving code reusability. (3) Maintainability: The split sub-functional blocks make the code easier to maintain. (4) Testability: Smaller, single-responsibility sub-functional blocks are easier to unit test, which helps improve the reliability and quality of the software. (5) Coupling and Cohesion: When splitting sub-functional blocks, coupling between sub-functional blocks should be minimized or avoided as much as possible, while improving the cohesion of each sub-functional block.
[0087] In one implementation, step 102 includes: determining the business logic of the functional block; applying the single responsibility principle to identify the sub-business logics in the business logic that each assume different responsibilities; and determining the sub-business logics as independently executable sub-functional blocks.
[0088] For example, suppose there's a shopping cart function block in an e-commerce platform. This block handles user actions in their shopping cart, including adding, deleting, and updating product quantities. Based on the above analysis, this function block can be broken down into finer-grained sub-blocks to improve code maintainability and reusability. For instance, the sub-blocks could include: a sub-block for adding products, a sub-block for deleting products, and a sub-block for updating product quantities, etc.
[0089] Step 102: Split the code of sub-functional blocks from the code of the functional block.
[0090] In one implementation, step 102 includes: determining the input parameters, output parameters, and business logic of the sub-functional block; obtaining a general template suitable for carrying the code, the general template inheriting the constraints of the development platform of the development project; writing the business logic code into the general template; setting the input interface of the general template based on the input parameters of the sub-functional block; and setting the output interface of the general template based on the output parameters of the sub-functional block. The constraints of the development platform may include: protocol stack constraints, software specifications, and data management specifications. Therefore, splitting the code of the sub-functional block based on the constraints of the development platform of the development project facilitates its subsequent use by the development project.
[0091] In one implementation, determining the input and output parameters of a sub-functional block includes: determining the dependencies of the sub-functional block based on the data flow analysis results, event flow analysis results, or function flow analysis results; and determining the input and output parameters of the sub-functional block based on the dependencies. The input parameters represent the sub-functional block's dependencies on entities outside the sub-functional block, and the output parameters represent the dependencies of entities outside the sub-functional block on the sub-functional block. Therefore, based on the dependencies of the sub-functional blocks, the interfaces of the sub-functional blocks can be conveniently implemented.
[0092] In the above process: Data flow analysis is used to understand the data flow relationships between sub-functional blocks, thereby helping to determine their dependencies. These data flow relationships can be between single functional blocks or span multiple functional blocks. Event flow analysis is used to understand the event triggering relationships between sub-functional blocks, thereby helping to determine their dependencies. These event triggering relationships can be between single functional blocks or span multiple functional blocks. Function flow analysis is used to understand the function execution order between sub-functional blocks, which helps to determine the dependencies between functional modules.
[0093] The dependencies between sub-functional blocks are directly related to their input and output parameters. The input parameters of a sub-functional block typically reflect its dependence on external data. If a sub-functional block needs to obtain data from other sub-functional blocks or external systems, this data will be passed as its input parameters. Input parameters define the interface through which data flows into the sub-functional block. The output parameters of a sub-functional block show the dependencies of other sub-functional blocks or system components on that sub-functional block. If the output of a sub-functional block needs to be used by other sub-functional blocks, these results will be passed as output parameters. Output parameters define the interface through which data flows out of the sub-functional block; this data is processed by the sub-functional block and provided to other parts.
[0094] When setting the input and / or output interfaces of a general template based on the input and / or output parameters of a sub-functional block, an abstraction layer can be used to define the interface (e.g., using an interface or abstract class in object-oriented programming). Method signatures (including method name, input parameters, and return type) can also be defined, where the interface specification needs to conform to the constraints of the development foundation of the project.
[0095] Step 103: Publish the code of the sub-function block as a package to the Package Manager.
[0096] A package manager is a software tool used to automate and manage dependencies in the software development process. It helps developers install, configure, update, and manage third-party libraries and tools used in a project. For example, a package manager can be implemented as an NPM management platform, a Yarn management platform for managing JavaScript packages, a PIP management platform for managing Python packages, and so on.
[0097] In one implementation, step 103 includes: building a generic template into a package suitable for publishing to a package manager based on a build command; and publishing the package suitable for publishing to the package manager to the package manager based on a publish command.
[0098] Let's take a package manager as the NPM management platform as an example. You can first execute the `npm run build` command or other build commands to package the code of the sub-functional blocks into a format suitable for distribution, and then execute the `npm publish` command to publish the package to the NPM management platform.
[0099] Step 104: In response to the triggering operation, determine the packages to be installed into the development project.
[0100] In one implementation, step 104 includes: displaying an icon for each package in the package manager in a graphical user interface; selecting at least one icon from the graphical user interface in response to a trigger operation triggered in the graphical user interface; and determining at least one package corresponding to at least one icon as a package to be installed into the development project.
[0101] Here, based on the needs of the development project, the necessary packages are identified. Then, in the graphical user interface displaying the icons of each package in the package manager, selecting at least one icon will identify at least one package corresponding to that icon, thus determining the packages to be installed into the development project.
[0102] Step 105: Obtain the packages to be installed into the development project from the package manager.
[0103] Here, the development project obtains packages to be installed into the development project from the package manager (for example, by downloading them from a package manager located in the cloud).
[0104] Step 106: Install the package to be installed in the development project.
[0105] For example, you can use the npm install command to install packages that need to be installed into your development project.
[0106] Figure 2 This is an exemplary structural diagram of a system for installing sub-functional blocks according to an embodiment of the present invention. Figure 2 As shown, the system for installing sub-functional blocks includes a publishing device 10, a package manager 11, and a development device 12 for development projects.
[0107] The publishing device 10 is used to determine independently executable sub-functional blocks from the functional blocks; split the code of the sub-functional blocks from the code of the functional blocks; and publish the code of the sub-functional blocks as packages to the package manager 11. The package manager 11 is used to manage packages; the development device 12 is used to determine the packages to be installed into the development project in response to a trigger operation; obtain the packages to be installed into the development project from the package manager 11; and install the packages to be installed into the development project.
[0108] In one implementation, package manager 11 is located in the cloud; package manager 11 is used to perform at least one of the following: package installation management; package version management; package dependency update management; global and local package management; package release management.
[0109] The following explanation uses a package manager as an example of an NPM package management platform. Figure 3 This is an exemplary schematic diagram illustrating the generation of NPM packages according to an embodiment of the present invention. Figure 3 As shown, function block 20 includes sub-function block 21, sub-function block 22, sub-function block 23, and sub-function block 24. The data flow between sub-function blocks 21, 22, 23, and 24 is as follows: Figure 3 As shown. Sub-function block 21 and sub-function block 22 have bidirectional data interaction; sub-function block 22 also has bidirectional data interaction with sub-function block 23; sub-function block 23 also has bidirectional data interaction with sub-function block 24. After data flow analysis, data flow analysis result 40 is obtained.
[0110] Data flow analysis results 40 include:
[0111] (1) The input parameter 25 of sub-function block 21 includes: the first output parameter of sub-function block 22; the output parameter 26 of sub-function block 21 includes: the first input parameter of sub-function block 22.
[0112] (2) The input parameter 27 of sub-function block 22 includes: the output parameter 26 of sub-function block 21 and the first output parameter of sub-function block 23; the output parameter 28 of sub-function block 22 includes: the input parameter 25 of sub-function block 21 and the first input parameter of sub-function block 23.
[0113] (3) The input parameter 29 of sub-function block 23 includes: the second output parameter of sub-function block 22 and the output parameter of sub-function block 24; the output parameter 30 of sub-function block 23 includes: the second input parameter of sub-function block 22 and the input parameter of sub-function block 24.
[0114] (3) The input parameter 31 of sub-function block 24 includes: the second output parameter of sub-function block 23; the output parameter 32 of sub-function block 24 includes: the second input parameter of sub-function block 23.
[0115] In the general template 33, which inherits the constraints of the development foundation of the project, the business logic code of sub-functional block 21 is written. Furthermore, based on the input parameter 25 of sub-functional block 21, the input interface of the general template for writing the business logic code of sub-functional block 21 is set; based on the output parameter 26 of sub-functional block 21, the output interface of the general template for writing the business logic code of sub-functional block 21 is set. Based on the build and publish commands of the NPM management platform, the general template with the set input and output interfaces is published as the NPM package 51 of sub-functional block 21 in the cloud package manager 11.
[0116] Within the general template 33, which inherits the constraints of the development foundation of the project, the business logic code of sub-functional block 22 is written. Furthermore, based on the input parameter 27 of sub-functional block 22, the input interface of the general template for writing the business logic code of sub-functional block 22 is set; and based on the output parameter 28 of sub-functional block 22, the output interface of the general template for writing the business logic code of sub-functional block 22 is set. Based on the build and publish commands of the NPM management platform, the general template with the set input and output interfaces is published as the NPM package 52 of sub-functional block 22 in the cloud package manager 11.
[0117] Within the general template 33, which inherits the constraints of the development foundation of the project, the business logic code of sub-functional block 23 is written. Furthermore, based on the input parameter 29 of sub-functional block 23, the input interface of the general template for writing the business logic code of sub-functional block 23 is set; and based on the output parameter 30 of sub-functional block 23, the output interface of the general template for writing the business logic code of sub-functional block 23 is set. Based on the build and publish commands of the NPM management platform, the general template with the set input and output interfaces is published as the NPM package 53 of sub-functional block 23 in the cloud package manager 11.
[0118] Within the general template 33, which inherits the constraints of the development foundation of the project, the business logic code for sub-functional block 24 is written. Furthermore, based on the input parameters 31 of sub-functional block 24, the input interface of the general template for writing the business logic code of sub-functional block 24 is set; and based on the output parameters 32 of sub-functional block 24, the output interface of the general template for writing the business logic code of sub-functional block 24 is set. Based on the build and publish commands of the NPM management platform, the general template with the set input and output interfaces is published as an NPM package 54 of sub-functional block 24 in the cloud package manager 11.
[0119] Figure 4 This is a schematic diagram illustrating an exemplary process of installing sub-functional blocks according to an embodiment of the present invention. Figure 4 As shown, NPM packages 51-58 are published in the package manager 11 in the cloud.
[0120] In the graphical user interface 121 of the development device, icons for NPM packages 51 through 58 are displayed. Based on the requirements of development project 122, the user triggers a selection operation in the graphical user interface 121 to select the icons for NPM packages 51, 52, 54, and 56. In response to this selection operation, package manager 11 distributes NPM packages 51, 52, and 54 to development project 122 of the development device. In development project 122, NPM packages 51, 52, and 54 are installed.
[0121] Figure 5 This is an exemplary structural diagram of an apparatus for mounting sub-functional blocks according to an embodiment of the present invention. Figure 5 As shown, the apparatus 500 for installing sub-functional blocks includes: a first determining module 501, used to determine independently executable sub-functional blocks from functional blocks; a splitting module 502, used to split the code of sub-functional blocks from the code of functional blocks; a publishing module 503, used to publish the code of sub-functional blocks to a package manager in the form of packages; a second determining module 504, used to determine packages to be installed into the development project in response to a trigger operation; an obtaining module 505, used to obtain packages to be installed into the development project from the package manager; and an installation module 506, used to install packages to be installed into the development project.
[0122] In one implementation, the splitting module 502 is used to determine the input parameters, output parameters, and business logic of the sub-functional blocks; obtain a general template suitable for carrying the code, the general template inheriting the constraints of the development foundation of the development project; write the business logic code into the general template; set the input interface of the general template based on the input parameters of the sub-functional blocks; and set the output interface of the general template based on the output parameters of the sub-functional blocks.
[0123] In one implementation, the splitting module 502 is used to determine the dependencies of the sub-functional blocks based on the data flow analysis results, event flow analysis results, or function flow analysis results of the sub-functional blocks; and to determine the input parameters and output parameters of the sub-functional blocks based on the dependencies; wherein the input parameters represent the dependencies of the sub-functional blocks on things outside the sub-functional blocks, and the output parameters represent the dependencies of things outside the sub-functional blocks on the sub-functional blocks.
[0124] In one implementation, the publishing module 503 is used to build a package suitable for publishing to the package manager from a general template based on a build command; and to publish the package suitable for publishing to the package manager to the package manager based on a publish command.
[0125] In one implementation, the second determining module 504 is configured to display an icon of each package in the package manager in a graphical user interface; select at least one icon from the graphical user interface in response to a trigger operation triggered in the graphical user interface; and determine at least one package of at least one icon as a package to be installed into the development project.
[0126] In one implementation, the first determining module 501 is used to determine the business logic of the functional block; apply the single responsibility principle to identify the sub-business logic in the business logic that undertakes different responsibilities; and determine the sub-business logic as an independently executable sub-functional block.
[0127] The present invention also proposes an electronic device with a processor-memory architecture. Figure 6 This is a structural diagram of an electronic device according to an embodiment of the present invention. Figure 6 As shown, the electronic device 600 includes a processor 601, a memory 602, and a computer program stored in the memory 602 and executable on the processor 601. When executed by the processor 601, the computer program implements the method of mounting sub-functional blocks as described above. Specifically, the memory 602 can be implemented as various storage media such as electrically erasable programmable read-only memory (EEPROM), flash memory, and programmable programmable read-only memory (PROM). The processor 601 can be implemented as including one or more central processing units (CPUs) or one or more field-programmable gate arrays (FPGAs), wherein the FPGA integrates one or more CPU cores. Specifically, the CPU or CPU core can be implemented as a CPU, MCU, or DSP, etc.
[0128] It should be noted that not all steps and modules in the above processes and structural diagrams are mandatory; some steps or modules can be omitted as needed. The execution order of the steps is not fixed and can be adjusted as required. The division of modules is merely for the convenience of description and functional division. In actual implementation, a module can be implemented by multiple modules, and the functions of multiple modules can also be implemented by the same module. These modules can be located in the same device or in different devices.
[0129] The hardware modules in each embodiment can be implemented mechanically or electronically. For example, a hardware module may include specially designed permanent circuitry or logic devices (such as dedicated processors, such as FPGAs or ASICs) to perform specific operations. A hardware module may also include programmable logic devices or circuitry (such as general-purpose processors or other programmable processors) temporarily configured by software to perform specific operations. The choice between mechanical implementation, dedicated permanent circuitry, or temporarily configured circuitry (such as software-configured circuitry) can be made based on cost and time considerations.
[0130] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
[0131] In this patent application, nouns and pronouns relating to people are not limited to specific genders.
Claims
1. A method for installing sub-functional blocks, characterized in that, include: Identify (101) independently executable sub-functional blocks from the functional blocks; The code of the sub-functional block is split (102) from the code of the functional block; The code of the sub-functional block is published as a package to the package manager (103); In response to the triggering operation, determine (104) the packages to be installed into the development project; Obtain (105) the package to be installed into the development project from the package manager; Install (106) the package to be installed into the development project in the development project.
2. The method according to claim 1, characterized in that, The code of the sub-functional block, which is split from the code of the functional block (102), includes: Determine the input parameters, output parameters, and business logic of the sub-functional block; Obtain a general template suitable for carrying the code, wherein the general template inherits the constraints of the development foundation of the development project; Write the business logic code into the general template; Based on the input parameters of the sub-functional blocks, the input interface of the general template is set; Based on the output parameters of the sub-functional blocks, the output interface of the general template is set.
3. The method according to claim 2, characterized in that, The determination of the input and output parameters of the sub-functional block includes: Based on the data flow analysis results, event flow analysis results, or function flow analysis results of the sub-functional blocks, determine the dependencies of the sub-functional blocks; Based on the dependencies, the input parameters and output parameters of the sub-functional block are determined; wherein the input parameters represent the sub-functional block's dependencies on anything outside the sub-functional block, and the output parameters represent the dependencies of anything outside the sub-functional block on the sub-functional block.
4. The method according to claim 2, characterized in that, The step of publishing the code of the sub-functional block as a package (103) to the package manager includes: Based on the build command, the general template is built into a package suitable for publishing to the package manager; Based on the publish command, the package suitable for publication to the package manager is published to the package manager.
5. The method according to claim 1, characterized in that, In response to the triggering operation, the package to be installed into the development project is determined (104) to include: The icon of each package in the package manager is displayed in the graphical user interface; In response to the triggering operation triggered in the graphical user interface, at least one icon is selected from the graphical user interface; The package to be installed into the development project is determined by identifying at least one package corresponding to the at least one icon.
6. The method according to any one of claims 1-5, characterized in that, The method of determining (101) independently executable sub-functional blocks from the functional blocks includes: Determine the business logic of the functional block; Apply the Single Responsibility Principle to identify the sub-business logics within the aforementioned business logic that each bear different responsibilities; The sub-business logic is defined as the independently executable sub-functional block.
7. A device for mounting sub-functional blocks, characterized in that, include: The first determining module (501) is used to determine independently executable sub-functional blocks from the functional blocks; A splitting module (502) is used to split the code of the sub-functional block from the code of the functional block; The publishing module (503) is used to publish the code of the sub-functional block to the package manager in the form of a package; The second determination module (504) is used to determine the package to be installed into the development project in response to the trigger operation; The acquisition module (505) is used to acquire the package to be installed into the development project from the package manager; The installation module (506) is used to install the package to be installed into the development project.
8. The apparatus according to claim 7, characterized in that, The splitting module (502) is used to determine the input parameters, output parameters, and business logic of the sub-functional block; obtain a general template suitable for carrying the code, the general template inheriting the constraints of the development foundation of the development project; and write the code of the business logic into the general template. Based on the input parameters of the sub-functional blocks, the input interface of the general template is set; Based on the output parameters of the sub-functional blocks, the output interface of the general template is set.
9. The apparatus according to claim 8, characterized in that, The splitting module (502) is used to determine the dependencies of the sub-functional blocks based on the data flow analysis results, event flow analysis results, or function flow analysis results of the sub-functional blocks; Based on the dependencies, the input parameters and output parameters of the sub-functional block are determined; wherein the input parameters represent the sub-functional block's dependencies on anything outside the sub-functional block, and the output parameters represent the dependencies of anything outside the sub-functional block on the sub-functional block.
10. A system for installing sub-functional blocks, characterized in that, It includes a distribution device (10), a package manager (11), and a development device (12), wherein: The publishing device (10) is used to determine independently executable sub-functional blocks from the functional blocks; split the code of the sub-functional blocks from the code of the functional blocks; and publish the code of the sub-functional blocks to the package manager (11) in the form of a package. The package manager (11) is used to manage the package; The development device (12) is configured to, in response to a trigger operation, determine a package to be installed in the development project; obtain the package to be installed in the development project from the package manager (11); and install the package to be installed in the development project.
11. The system according to claim 10, characterized in that, The package manager (11) is located in the cloud; The package manager (11) is configured to perform at least one of the following: Package installation management; package version management; package dependency update management; global and local package management; package release management.
12. An electronic device, characterized in that, include: Processor (601); Memory (602) for storing executable instructions of the processor (601); The processor (601) is configured to read the executable instructions from the memory (602) and execute the executable instructions to implement the method of installing the sub-functional block according to any one of claims 1-6.
13. A computer-readable storage medium storing computer instructions thereon, characterized in that, When the computer instructions are executed by the processor, they implement the method of installing the sub-functional block as described in any one of claims 1-6.
14. A computer program product, characterized in that, Includes a computer program, which, when executed by a processor, implements the method of installing the sub-functional block as described in any one of claims 1-6.