Componentized methods and systems
By acquiring and configuring public components and building a component database, the resource redundancy problem caused by low business logic reusability is solved, the component reusability and system maintainability are improved, and the development process is simplified.
Patent Information
- Application Number
- CN202010575892.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-22
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2040-06-22
AI Technical Summary
The low reusability of business logic in existing systems leads to resource redundancy problems.
By obtaining public components, including public style components and business components, component definition and configuration are performed, and a component database is built to call and instantiate target components according to user requests, thereby improving component reusability.
It effectively reduces resource redundancy, improves component reusability and system maintainability, simplifies the development process, and reduces development costs.
Smart Images

Figure CN111736884B
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of base frame operation and maintenance, and in particular to a componentized method, system, device and computer-readable storage medium. Background Art
[0002] With the rapid development of computer technology and the Internet, computer applications are becoming more and more popular, application functions are becoming more and more powerful, and the problems they deal with are becoming more and more complex. When there are many complex business logics and complex page interactions, a large amount of repeated logic may appear, and some repeated logic may be reused. However, due to the differences in the granularity of different logic splits, the entire module may be loaded in order to rely on a certain function, which will cause a lot of resource redundancy problems.
[0003] It should be noted that the above content is not intended to limit the scope of protection of the invention. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a componentized method, system, computer device and computer-readable storage medium to solve the technical problem of low reusability of business logic of the current system and the resulting resource redundancy.
[0005] An aspect of an embodiment of the present invention provides a componentization method, which includes: obtaining multiple common components, wherein the common components include common style components and business components; performing a component definition operation on each common component, wherein the component definition operation includes component naming and component classification; performing a component configuration operation on each common component after the component definition operation to obtain multiple target components, wherein the component configuration operation includes an interface configuration operation; setting a component life cycle for each of the multiple target components; and constructing a component database based on the multiple target components after the setting, wherein the component database is used to call and instantiate corresponding target components according to user requests.
[0006] Optionally, the common style component includes an animation component, which is configured with an animation component interface, in which a detection function and a selection function are encapsulated; wherein: the detection function is configured to perform the following operations: detect the properties and version information of the browser, and determine whether the browser supports one of transitions and animations based on the properties and version information of the browser; and the selection function is configured to perform the following operations: determine whether the browser page executes animation effects through transitions or animations based on the output parameters of the detection function; if the browser supports both transitions and animations, detect the current running state of the browser, and determine whether the browser page executes animation effects through transitions or animations based on the current running state of the browser.
[0007] Optionally, the business component includes a functional component for executing corresponding business logic; the step of obtaining multiple common components also includes: obtaining business data from a preset database; extracting multiple business entities and relationship data between each business entity from the business data; constructing a business knowledge graph based on the relationship data between multiple business entities and each business entity; recording the number of times each business entity references other business entities in the business knowledge graph; analyzing the number of times each business entity is referenced according to the business knowledge graph; analyzing multiple target business entities whose number of references is higher than a preset threshold according to the number of times each business entity is referenced; and encapsulating the business logic code of each target business implementation into corresponding business components.
[0008] Optionally, the step of encapsulating the business logic codes of each target business implementation into corresponding business components includes: analyzing the feasibility of independent encapsulation of each target business entity; and encapsulating the business logic codes of the target business entities with independent encapsulation feasibility into corresponding business components.
[0009] Optionally, the step of analyzing the feasibility of independent encapsulation of each target business entity includes: determining whether the corresponding target business entity has functional independence; determining whether the corresponding target business entity satisfies the requirement of not having a separate routing configuration; determining whether the corresponding target business entity satisfies the requirement of not involving data flow; and if the corresponding target business entity has functional independence, does not have a separate routing configuration and does not involve data flow, determining that the corresponding target business entity is a target business entity with independent encapsulation feasibility.
[0010] Optionally, the step of performing component definition operation on each common component includes: defining corresponding component names for each common component, the component names including a prefix, a name and a modifier; wherein the prefix is used to ensure the uniqueness of the corresponding common component and to identify the set to which the corresponding common component belongs, the name is used to describe the function or attribute of the corresponding common component; and the modifier is used to distinguish the corresponding common component from other coupled components.
[0011] Optionally, the method further includes the steps of managing the component life cycle of each target component: analyzing the negative impact of each target component on the system during its creation or operation; determining the target components with negative impact as target components to be destroyed, and monitoring the current operation stage of the target components to be destroyed in real time; and destroying the target components to be destroyed if it is monitored that the process of the target components to be destroyed has ended.
[0012] One aspect of an embodiment of the present invention further provides a componentized system, which includes: an acquisition module for acquiring multiple common components, wherein the common components include common style components and business components; a component definition module for performing component definition operations on each common component, wherein the component definition operations include component naming and component classification; a component configuration module for performing component configuration operations on each common component after the component definition operation to obtain multiple target components, wherein the component configuration operations include interface configuration operations; a component setting module for setting a component life cycle for each of the multiple target components; and a construction module for constructing a component database based on the multiple target components after the setting, wherein the component database is used to call and instantiate corresponding target components according to user requests.
[0013] An aspect of an embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned componentization method when executing the computer program.
[0014] An aspect of an embodiment of the present invention further provides a computer-readable storage medium, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned componentization method when executing the computer program.
[0015] The componentization method, system, device and computer-readable storage medium provided by the embodiments of the present invention define and configure multiple "common components" for re-componentization to obtain multiple corresponding "target components". These target components are stored in a component database for repeated system calls, effectively improving component reusability and reducing resource redundancy. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 A flowchart of a componentization method according to Embodiment 1 of the present invention is schematically shown;
[0017] Figure 2 A block diagram of a componentized system according to a second embodiment of the present invention is schematically shown; and
[0018] Figure 3 A schematic diagram of the hardware architecture of a computer device suitable for implementing the componentization method according to the third embodiment of the present invention is shown schematically. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0020] It should be noted that the descriptions involving "first", "second", etc. in the embodiments of the present invention are only for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0021] Embodiment 1
[0022] Figure 1 The flowchart of the componentization method according to the first embodiment of the present invention is schematically shown. It can be understood that the flowchart in the embodiment of the method is not used to limit the order of executing steps. The following is an exemplary description using the computer device 2 as the execution subject.
[0023] like Figure 1 As shown, the componentization method may include steps S100 to S108, wherein:
[0024] Step S100, obtaining multiple common components.
[0025] The multiple common components may include page basic controls, basic logic function components, common style components and business components.
[0026] The multiple common components have the following characteristics: ① responsible for a relatively independent and stable function; ② no separate routing configuration; ③ can be purely static, or contain its own state, but does not involve data flow, and is only controlled by parameters passed by the parent component (usually a page).
[0027] The basic page controls are controls for basic common functions, and these common functions are relatively independent; for example, Button, CheckBox, Radio, etc. These basic controls are usually reusable.
[0028] The basic logic function components mainly refer to some function components composed of basic logic that are not related to the interface; for example, components that encapsulate pure logic functions such as DOM operations, time and date, tools or verification.
[0029] The common style components refer to components encapsulated by basic styles or atomic styles; for example, components with some smaller logic encapsulation such as clear floats and common animation styles. The clear floats: use the clear attribute of CSS to define that elements adjacent to floats are displayed in a new line when necessary, and control the floating elements to be displayed in a bank. The clear attribute has four values: left, right, both and none. This type of display control is a high-frequency setting for most pages, so it can be encapsulated as a common component to achieve code sharing. The common animation styles include transforms, transitions and animations. Transitions and animations are used for transition animations. The transitions function supports the smooth transition of attributes from one value to another, thereby producing a gradient animation effect; the animations function supports the generation of sequence gradient animations through key frames; animation components that include both transitions and animations can be encapsulated to change the displacement, scaling, rotation, tilt and other operations of the object.
[0030] In an exemplary embodiment, the common style component includes an animation component, and the animation component is configured with an animation component interface. In order to achieve the technical effect of the browser switching between multiple screen effects according to the running state, the animation component interface encapsulates a detection function and a selection function. Among them: the detection function is configured to perform the following operations: detect the properties and version information of the browser, and determine whether the browser supports one of transitions and animations according to the properties and version information of the browser; the selection function is configured to perform the following operations: determine whether the browser page performs animation effects through transitions or animations according to the output parameters of the detection function; if the browser supports both transitions and animations, then detect the current running state of the browser, and determine whether the browser page performs animation effects through transitions or animations according to the current running state of the browser.
[0031] The business components are components extracted from functional modules that may be referenced multiple times, which can be easily managed in a unified manner.
[0032] In an exemplary embodiment, the business component may include a functional component for executing corresponding business logic. In order to obtain as many reusable business components as possible and effectively, the step S100 may further include the step of refining business components according to each functional module, specifically including steps S100a to 100g: Step S100a, obtaining business data from a preset database. Step S100b, extracting multiple business entities and relationship data between each business entity from the business data. Specifically, the business data may be logical function data corresponding to a functional module that is referenced multiple times, the multiple business entities include multiple functional modules that are referenced multiple times, and the relationship data between each business entity is reference relationship data between each functional module, wherein each functional module generates a reference record when it references other functional modules once. Step S100c, constructing a business knowledge graph based on the relationship data between multiple business entities and each business entity. Specifically, the computer device 2 can define multiple function module triples according to the reference relationship data between each function module, and construct a business knowledge graph according to the multiple function module triples. Each time each function module performs a reference operation on other function modules, it can be recorded in the form of a function module triple in the business knowledge graph. Among them, the newly generated function module triple can be judged according to the business knowledge graph. If there is no function module triple identical to the newly generated function module triple in the business knowledge graph, the newly generated function module triple is added to the business knowledge graph; if there is already a function module triple identical to the newly generated function module triple in the business knowledge graph, the number of applications corresponding to the function module triple is accumulated. Step S100d, record the number of references of each business entity to other business entities in the business knowledge graph. Step S100e, analyze the number of references of each business entity according to the business knowledge graph. Step S100f, based on the number of times each business entity is cited, multiple target business entities with a number of citations higher than a preset threshold are analyzed. Specifically, the number of times each functional module is applied is analyzed from the business knowledge graph, and the functional modules with a number of applications higher than the preset threshold are used as target functional modules to obtain multiple target functional modules. Step S100g, the business logic codes implemented by each target business are respectively encapsulated into corresponding business components.
[0033] Specifically, the computer device 2 analyzes the independent encapsulation feasibility information of each target function module in multiple target business entities (ie, target function modules), and encapsulates the corresponding business logic codes in the target function modules with independent encapsulation feasibility into common business components.
[0034] In an exemplary embodiment, in order to avoid encapsulating some invalid components, step S100g may include the following steps: analyzing the feasibility of independent encapsulation of each target business entity; encapsulating the business logic code of the target business entity with independent encapsulation feasibility into the corresponding business component. It is not difficult to understand that the business logic code of the target business entity that does not have the feasibility of independent encapsulation will not be encapsulated into the corresponding business component.
[0035] In an exemplary embodiment, the feasibility of independent encapsulation of each target business entity can be obtained through the following steps: determining whether the corresponding target business entity has functional independence; determining whether the corresponding target business entity satisfies the requirement of not having a separate routing configuration; determining whether the corresponding target business entity satisfies the requirement of not involving data flow; if the corresponding target business entity has functional independence, does not have a separate routing configuration and does not involve data flow, then determining that the corresponding target business entity is a target business entity with independent encapsulation feasibility; otherwise, determining that the target business entity is a target business entity that is not feasible for independent encapsulation, that is, the business logic code corresponding to the target business entity is not suitable for encapsulation into a business component among the multiple common components.
[0036] Step S102: performing component definition operation on each common component, wherein the component definition operation includes component naming and component classification.
[0037] The computer device 2 can classify and define each common component as needed.
[0038] In an exemplary embodiment, in order to improve the efficiency of component management, the step S102 may include step S102a: defining a corresponding component name for each of the common components, wherein the component name includes a prefix, a name, and a modifier. The prefix is used to ensure the uniqueness of the corresponding common component and to identify the set to which the corresponding common component belongs, the name is used to describe the function or attribute of the corresponding common component, and the modifier is used to distinguish the corresponding common component from other coupled components.
[0039] In order to better uniformly manage, extract, display and call these common components, this embodiment names and classifies the common components.
[0040] The component naming of the common component after the component naming may include a prefix, a name and a modifier;
[0041] The prefix is used to ensure the uniqueness of the corresponding common component to prevent conflicts with other components, and to quickly identify the set of corresponding common components. <cui->Prefixes of the form, such as <cui-button>In some embodiments, prefixes play an important role when creating a collection of common components. For example, web components have no scope because they are declared globally in a web page, which means that a "unique" prefix is required to prevent conflicts. In addition, web components need to include a "-" hyphen in the tag name, so the component naming includes a prefix.
[0042] The names are used to describe the functions or properties of the corresponding common components. Each common component is not an action, but a "thing" in concept, so the names are all nouns, such as "animation" instead of "animating". Exemplary names may be "animation", "input", "tab", "navigation" and "menu", etc.
[0043] The modifier is used to distinguish the corresponding common component from other coupled components. When several components are related or coupled and can share component names, these components can be distinguished by adding different modifiers, for example: <cui-card> 、 <cui-card-header> 、 <cui-card-content>.
[0044] Exemplarily, the component definition operation may also include customization of component themes. For example, a theme style definition may be performed based on the diverse visual needs of the business and brand, and the theme style definition includes the style definition of the primary color, rounded corners, borders, and some components. In some embodiments, Less / Sass may be used as a development language to define a series of global / component theme style variables, and these theme style variables may be customized by overwriting variables, and the theme style may be adjusted accordingly based on demand. For example, the theme style variables may include: global primary color, link color, warning color, component floating layer rounded corners, primary text color, title color, invalid color, and border color, etc.
[0045] Step S104, performing component configuration operation for each common component after the component definition operation to obtain multiple target components, wherein the component configuration operation includes an interface configuration operation.
[0046] The computer device 2 may perform a standard interface configuration operation for each of the common components, wherein the interface configuration operation includes configuring a request interface and a response interface, and determining the required input values and the corresponding outputs through the configured request interface and response interface.
[0047] Exemplarily, the interface configuration operation also includes the configuration of the default display of the component and the configuration of the dynamic component. The content displayed by the default component is to display the default content of the component according to the input value received by the response interface; the dynamic component is reflected in that the content of the common component can be dynamically adjusted. For example, there is a text, a picture and a button in a common component. Then the font, color, whether the picture is displayed or not, the position of the button, the processing logic of the button click event, etc. can all be made configurable. For example, the configured value is passed to the common component through the attribute, and then during the life cycle of the common component initialization, the corresponding modification and display are performed by reading the value of the attribute. Of course, it is also possible to call the function exposed by the common component, pass a valid value to the function, modify the global style, pass a specific event to the common component, and listen to the event in the common component to execute the function, etc. In addition, in order to make the common component more robust and ensure that the common component receives valid attributes and the function receives valid parameters, some verification rules can also be configured.
[0048] Step S106: setting a component lifecycle for each target component in the multiple target components.
[0049] The component life cycle includes beforeCreate (component initialization), created (component instantiation), beforeMount, mounted (component addition), beforeUpdate, updated (component loading), beforeDestroy, destroyed (component destruction), etc.
[0050] In an exemplary embodiment, in order to reduce the burden on the computer device 2 and improve the stability of the system operation, the componentization method may also include: ① the step of managing the component life cycle of each target component; ② analyzing the negative impact of each target component on the system during creation or operation, such as possible system crashes, etc.; ③ determining the target components with negative impacts as target components to be destroyed, and monitoring the current operation stage of the target components to be destroyed in real time; ④ if it is monitored that the process of the target component to be destroyed has ended, destroying the target component to be destroyed.
[0051] In some embodiments, before the public component is instantiated, an initialization event is generated. After the instantiation is completed, the properties and methods of the public component are added to the created component instance through traversal; the component template is compiled to combine the data and template and render it into a DOM tree; the DOM structure of the public component is loaded into the corresponding DOM node; and finally, the public component is destroyed, unbinding, destroying the child components and event listeners, and ending the component life cycle.
[0052] Step S108, constructing a component database according to the set multiple target components, and the component database is used to call and instantiate corresponding target components according to user requests.
[0053] The component database may be configured with a component API (Application Programming Interface) for component calling, which is used to call and instantiate corresponding target components according to user requests.
[0054] The componentization solution provided in the first embodiment of the present invention defines and configures multiple "common components" to be re-componentized, and obtains multiple corresponding "target components". These target components are stored in the component database for repeated system calls, which effectively improves the component reusability. In addition, while providing component reusability, the re-componentization of multiple "common components" also improves component testability, automated testing, etc., improves maintainability, and each component has a single responsibility and is easier to reuse. If modifications are required, only one modification is required, and independent components are easier to understand; the coupling of the system is reduced, the aggregation of functions within the system is improved, and the scalability of the system is improved. While keeping the interface unchanged, one component can be replaced by another component, thereby achieving functional upgrades; effectively reducing the complexity of development, improving development efficiency, and reducing development costs.
[0055] Embodiment 2
[0056] Figure 2 A block diagram of a componentized system according to Embodiment 2 of the present invention is schematically shown. The componentized system can be divided into one or more program modules, and one or more program modules are stored in a storage medium and executed by one or more processors to complete the embodiment of the present invention. The program module referred to in the embodiment of the present invention refers to a series of computer program instruction segments that can complete specific functions. The following description will specifically introduce the functions of each program module in this embodiment.
[0057] like Figure 2 As shown, the componentized system 200 may include an acquisition module 210, a component definition module 220, a component configuration module 230, a configuration module 240 and a construction module 250, wherein:
[0058] An acquisition module 210, used to acquire a plurality of common components, wherein the common components include common style components and business components;
[0059] A component definition module 220, used to perform component definition operations on each common component, wherein the component definition operations include component naming and component classification;
[0060] A component configuration module 230, configured to perform a component configuration operation for each common component after the component definition operation to obtain multiple target components, wherein the component configuration operation includes an interface configuration operation;
[0061] A component setting module 240, configured to set a component life cycle for each target component of the plurality of target components; and
[0062] The construction module 250 is used to construct a component database according to the set multiple target components, wherein the component database is used to call and instantiate corresponding target components according to user requests.
[0063] In an exemplary embodiment, the common style component includes an animation component, and the animation component is configured with an animation component interface, in which a detection function and a selection function are encapsulated; wherein: the detection function is configured to perform the following operations: detect the properties and version information of the browser, and determine whether the browser supports one of transitions and animations based on the properties and version information of the browser; and the selection function is configured to perform the following operations: determine whether the browser page executes animation effects through transitions or animations based on the output parameters of the detection function; if the browser supports both transitions and animations, detect the current running state of the browser, and determine whether the browser page executes animation effects through transitions or animations based on the current running state of the browser.
[0064] In an exemplary embodiment, the business component includes a functional component for executing corresponding business logic; the acquisition module 210 is also used to: acquire business data from a preset database; extract multiple business entities and relationship data between each business entity from the business data; construct a business knowledge graph based on the relationship data between multiple business entities and each business entity; record the number of times each business entity references other business entities in the business knowledge graph; analyze the number of times each business entity is referenced according to the business knowledge graph; analyze multiple target business entities whose number of references is higher than a preset threshold according to the number of times each business entity is referenced; and encapsulate the business logic code of each target business implementation into corresponding business components.
[0065] In an exemplary embodiment, the acquisition module 210 is further used to: analyze the feasibility of independent encapsulation of each target business entity; and encapsulate the business logic code of the target business entity with independent encapsulation feasibility into a corresponding business component.
[0066] In an exemplary embodiment, the acquisition module 210 is also used to: determine whether the corresponding target business entity has functional independence; determine whether the corresponding target business entity satisfies the requirement of not having a separate routing configuration; determine whether the corresponding target business entity satisfies the requirement of not involving data flow; and if the corresponding target business entity has functional independence, does not have a separate routing configuration and does not involve data flow, determine that the corresponding target business entity is a target business entity with independent encapsulation feasibility.
[0067] In an exemplary embodiment, the component definition module 220 is also used to: define corresponding component names for each of the common components, and the component names include a prefix, a name, and a modifier; wherein the prefix is used to ensure the uniqueness of the corresponding common component and to identify the set to which the corresponding common component belongs, the name is used to describe the function or attribute of the corresponding common component; and the modifier is used to distinguish the corresponding common component from other coupled components.
[0068] In an exemplary embodiment, a lifecycle management module (not shown) is also included to manage the component lifecycle of each target component: analyzing the negative impact of each target component on the system during creation or operation; determining the target components with negative impact as target components to be destroyed, and monitoring the current operation stage of the target components to be destroyed in real time; and destroying the target component to be destroyed if it is monitored that the process of the target component to be destroyed has ended.
[0069] Embodiment 3
[0070] Figure 3 The hardware architecture diagram of a computer device 2 suitable for implementing the componentization method according to the third embodiment of the present invention is schematically shown. In this embodiment, the computer device 2 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. For example, it can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a rack server, a blade server, a tower server or a cabinet server (including an independent server, or a server cluster composed of multiple servers), etc. Figure 3 As shown, the computer device 2 includes at least but is not limited to: a memory 310, a processor 320, and a network interface 330 which can communicate with each other through a system bus. Among them:
[0071] The memory 310 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 310 can be an internal storage module of the computer device 2, such as a hard disk or memory of the computer device 2. In other embodiments, the memory 310 can also be an external storage device of the computer device 2, such as a plug-in hard disk equipped on the computer device 2, a smart memory card (SmartMedia Card, referred to as SMC), a secure digital (Secure Digital, referred to as SD) card, a flash card, etc. Of course, the memory 310 can also include both the internal storage module of the computer device 2 and its external storage device. In this embodiment, the memory 310 is generally used to store the operating system and various application software installed on the computer device 2, such as the program code of the componentization method, etc. In addition, the memory 310 can also be used to temporarily store various types of data that have been output or are to be output.
[0072] The processor 320 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 320 is generally used to control the overall operation of the computer device 2, such as performing control and processing related to data interaction or communication with the computer device 2. In this embodiment, the processor 320 is used to run the program code stored in the memory 310 or process data.
[0073] The network interface 330 may include a wireless network interface or a wired network interface, and the network interface 330 is generally used to establish a communication link between the computer device 2 and other computer devices. For example, the network interface 330 is used to connect the computer device 2 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 2 and the external terminal. The network can be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.
[0074] It should be pointed out that Figure 3 Only a computer device having components 310 - 330 is shown, but it should be understood that implementing all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.
[0075] In this embodiment, the componentized method stored in the memory 310 may also be divided into one or more program modules and executed by one or more processors (processor 320 in this embodiment) to complete the embodiment of the present invention.
[0076] Embodiment 4
[0077] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the componentization method in the embodiment are implemented.
[0078] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the computer-readable storage medium can be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium can also be an external storage device of a computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, referred to as SMC), a secure digital (Secure Digital, referred to as SD) card, a flash card (Flash Card), etc. Of course, the computer-readable storage medium can also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the computer-readable storage medium is generally used to store the operating system and various application software installed on the computer device, such as the program code of the componentization method in the embodiment, etc. In addition, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or are to be output.
[0079] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.
[0080] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention. < / cui-card-header> < / cui-card>
Claims
1. A componentized approach, It is characterized in that The method comprises: Acquire multiple common components, wherein the common components include common style components and business components; Performing a component definition operation on each common component, wherein the component definition operation includes component naming and component classification; Performing component configuration operation for each common component after the component definition operation to obtain multiple target components, wherein the component configuration operation includes an interface configuration operation; Setting a component lifecycle for each target component of the plurality of target components; and Building a component database according to the set multiple target components, the component database is used to call and instantiate the corresponding target components according to user requests; The common style component includes an animation component, and the animation component is configured with an animation component interface, in which a detection function and a selection function are encapsulated; wherein: The detection function is configured to perform the following operations: detecting the properties and version information of the browser, and determining whether the browser supports one of transitions and animations according to the properties and version information of the browser; and The selection function is configured to perform the following operations: determine, according to the output parameter of the detection function, that the page of the browser performs animation effects through transitions or animations; if the browser supports both transitions and animations, detect the current running state of the browser, and determine, according to the current running state of the browser, that the page of the browser performs animation effects through transitions or animations; The business component includes a functional component for executing corresponding business logic; the step of obtaining multiple common components also includes: Get business data from the preset database; Extracting multiple business entities and relationship data between each business entity from the business data; Build a business knowledge graph based on multiple business entities and the relationship data between each business entity; Recording the number of times each business entity references other business entities in the business knowledge graph; Analyze the number of citations of each business entity according to the business knowledge graph; Analyzing multiple target business entities whose citation counts are higher than a preset threshold according to the citation counts of each business entity; and Encapsulate the business logic codes of each target business implementation into corresponding business components.
2. The componentization method according to claim 1, It is characterized in that The step of respectively encapsulating the business logic codes of each target business implementation into corresponding business components includes: Analyze the feasibility of independent packaging of each target business entity; Encapsulate the business logic code of the target business entity that is feasible for independent encapsulation into corresponding business components.
3. The componentization method according to claim 2, It is characterized in that The step of analyzing the feasibility of independent packaging of each target business entity includes: Determine whether the corresponding target business entity has functional independence; Determining whether the corresponding target service entity satisfies the requirement of not having a separate routing configuration; Determine whether the corresponding target service entity meets the requirement of not involving data flow; and If the corresponding target service entity has functional independence, does not have a separate routing configuration, and does not involve a data flow, it is determined that the corresponding target service entity is a target service entity with independent encapsulation feasibility.
4. The componentization method according to claim 1, It is characterized in that The step of performing component definition operation on each common component includes: Defining corresponding component names for each of the common components, wherein the component names include a prefix, a name, and a modifier; Among them, the prefix is used to ensure the uniqueness of the corresponding common component and to identify the set to which the corresponding common component belongs, the name is used to describe the function or attribute of the corresponding common component; and the modifier is used to distinguish the corresponding common component from other coupled components.
5. The componentization method according to claim 1, It is characterized in that It also includes steps to manage the component lifecycle of each target component: Analyze the negative impact of each target component on the system during creation or operation; Determine the target component with negative impact as the target component to be destroyed, and monitor the current running stage of the target component to be destroyed in real time; and If it is monitored that the process of the target component to be destroyed has ended, the target component to be destroyed is destroyed.
6. A componentized system, It is characterized in that include: An acquisition module, used for acquiring a plurality of common components, wherein the common components include common style components and business components; A component definition module, used to perform component definition operations on each common component, wherein the component definition operations include component naming and component classification; A component configuration module, used for performing a component configuration operation for each common component after the component definition operation to obtain multiple target components, wherein the component configuration operation includes an interface configuration operation; a component setting module, configured to set a component life cycle for each target component among the plurality of target components; and A construction module, used to construct a component database according to the set multiple target components, wherein the component database is used to call and instantiate the corresponding target components according to user requests; The common style component includes an animation component, and the animation component is configured with an animation component interface, in which a detection function and a selection function are encapsulated; wherein: The detection function is configured to perform the following operations: detecting the properties and version information of the browser, and determining whether the browser supports one of transitions and animations according to the properties and version information of the browser; and The selection function is configured to perform the following operations: determine, according to the output parameter of the detection function, that the page of the browser performs animation effects through transitions or animations; if the browser supports both transitions and animations, detect the current running state of the browser, and determine, according to the current running state of the browser, that the page of the browser performs animation effects through transitions or animations; The business component includes a functional component for executing corresponding business logic; the step of obtaining multiple common components also includes: Get business data from the preset database; Extracting multiple business entities and relationship data between each business entity from the business data; Build a business knowledge graph based on multiple business entities and the relationship data between each business entity; Recording the number of times each business entity references other business entities in the business knowledge graph; Analyze the number of citations of each business entity according to the business knowledge graph; Analyzing multiple target business entities whose citation counts are higher than a preset threshold according to the citation counts of each business entity; and Encapsulate the business logic codes of each target business implementation into corresponding business components.
7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the processor is used to implement the steps of the componentization method according to any one of claims 1 to 5.
8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and the computer program can be executed by at least one processor to enable the at least one processor to perform the steps of the componentization method according to any one of claims 1 to 5.
