Modularization-based code compatibility method and system and readable medium

By disassembling the code logic of the application software system into modules and defining interface projects and sub-engineers, the problem of microservices and monolithic architectures requiring two sets of code is solved, and the effect of code compatibility and cost reduction is achieved.

CN119883243APending Publication Date: 2025-04-25YOZOSOFT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411946346.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In the prior art, projects of microservice architecture and monolithic architecture require two sets of code to be written, resulting in increased R&D and maintenance costs.

Method used

By disassembling the code logic of the application software system into business function modules and technical component function modules, and defining interface projects and sub-engines, using jar package, feign or dubbo to generate shell projects to achieve code compatibility.

Benefits of technology

It realizes a set of code-compatible microservices and monolithic architecture styles, reducing code duplication and reducing R&D and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883243A_ABST
    Figure CN119883243A_ABST
Patent Text Reader

Abstract

The invention provides a code compatibility method and system based on modularization and a computer readable medium. The method comprises the steps that code logic of an application software system is disassembled into a service function module and a technical component function module, the service function module is defined as an independent project, and the technical component function module is defined as an independent project; defining an interface project for calling an independent project, wherein the interface project only comprises an interface definition; defining a sub-project inheriting the interface project, wherein the sub-project calls the interface project by adopting a jar package calling mode, a feed calling mode or a dubbo package calling mode; and generating one or more shell projects, and integrating the interface projects and the sub-projects into the shell projects. Codes written by the method can be compatible with two architecture styles of micro-service and monomers, so that a set of codes can be used, repeated writing of the codes is reduced, and research, development and maintenance costs are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a modular-based code compatibility method, system and readable medium. Background Art

[0002] With the continuous development of microservice architecture style, more and more projects use this style. However, due to the limitation of project scale and user volume, there are still many scenarios where the monolithic architecture style is applicable. Two sets of code need to be written for the two styles of architecture, which increases R&D and maintenance costs.

[0003] Therefore, it is necessary to propose a new technical solution. Summary of the invention

[0004] In order to solve the technical problems existing in the prior art, the present invention discloses a modular-based code compatibility method, system and readable medium.

[0005] In one aspect, the present invention provides a modular-based code compatibility method, comprising:

[0006] S1. Decompose the code logic of the application software system into a business function module and a technical component function module, define the business function module as a separate project, and define the technical component function module as a separate project;

[0007] S2, define an interface project that calls the separate project in step S1, and the interface project only includes interface definition;

[0008] S3. Define a sub-project that inherits the interface project in step S2. The sub-project uses the jar package calling method, the feign calling method, or the dubbo package calling method to call the interface project in step S1.

[0009] S4. Generate one or more shell projects, and integrate the interface project in step S2 and the sub-project in step S3 into the shell project.

[0010] Furthermore, the shell project consists of configuration function logic and startup function logic.

[0011] Further, S3, define a sub-project that inherits the interface project in step S2, and the sub-project uses a jar package calling method, a feign calling method, or a dubbo package calling method to call the interface project in step S1; specifically including:

[0012] Define a sub-project that inherits the interface project in step S2. When the software architecture of the application software system is a monolithic architecture, the sub-project calls the interface project using a jar package call.

[0013] When the software architecture of the application software system is the spring cloud alibaba microservice architecture, the sub-project uses the openfeign calling method to call the interface project;

[0014] When the software architecture of the application software system is the dubbo microservice architecture, the sub-project uses the dubbo package calling method to call the interface project.

[0015] Further, S4, generating one or more shell projects, integrating the interface project in step S2 and the sub-project in step S3 into the shell project, specifically including:

[0016] When the software architecture of the application software system is a monolithic architecture, a shell project is generated, and the interface project in step S2 and the jar package in step S3 are integrated into the shell project;

[0017] When the software architecture of the application software system is a microservice architecture, multiple shell projects are generated, and the interface project in step S2 and the spring cloud alibaba package or dubbo package in step S3 are integrated into the shell project.

[0018] Furthermore, the sub-project also adopts the asynchronous calling method of MQ.

[0019] On the other hand, the present invention also provides a modular-based code compatibility system, which includes:

[0020] A disassembly module is used to disassemble the code logic of the application software system into a business function module and a technical component function module, define the business function module as a separate project, and define the technical component function module as a separate project;

[0021] A definition module is used to define an interface project that calls a separate project. The interface project only includes interface definitions.

[0022] The definition module is also used to define a sub-project that inherits the interface project, and the sub-project uses a jar package calling method, a feign calling method, or a dubbo package calling method to call the interface project;

[0023] A generation module is used to generate one or more shell projects and integrate the interface project and the sub-project into the shell project.

[0024] In another aspect, the present invention further provides a computer-readable medium storing a computer program for executing the above method.

[0025] The present invention is based on a modular code compatibility method and has the following beneficial effects:

[0026] The code compatibility method of the present invention can compile codes that are compatible with both microservice and monolithic architecture styles, so that a set of codes can be used, reducing repeated code writing and reducing R&D and maintenance costs.

[0027] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 This is a schematic diagram of the structure of a monomer package according to the present invention;

[0029] Figure 2 This is a schematic diagram of the structure of a micro-server package according to the present invention;

[0030] Figure 3 This is a flow chart of the modularized code compatibility method of the present invention. DETAILED DESCRIPTION

[0031] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the specific implementation methods, structures, features and effects of the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments.

[0032] Monolith and microservices are two different architectural styles. Microservices are disassembled from the perspective of business on the basis of monoliths, and each service has its own communication method. In order to achieve a set of code compatible with two architectural styles. The present invention splits each actual code logic in a modular manner, which only includes business functions and technical component function logic, and does not include communication, configuration and startup functions. Physically, each module exists in the form of a separate project, and is finally packaged into a jar form. In the scenario of a monolith, a shell with configuration and startup is generated to introduce all jar packages; in the scenario of microservices, different shells with configuration and startup functions are encapsulated to generate multiple microservices, which are physically deployed separately and managed through the springc loud al ibaba framework. It can also be expanded into other microservice frameworks.

[0033] Figure 1 The present invention is directed to a schematic diagram of a monomer package structure; Figure 2 The present invention is directed to a schematic diagram of the micro-server package structure; Figure 3 FIG. 1 is a flow chart of the modular code compatibility method of the present invention. Figure 1 and Figure 2 As shown, Figure 1Here, monomer-server is the service layer of the monolithic application, Service A is the business layer service A, and Service B is the business layer B. The business layer calls the shell layer interface and finally transfers it to the jar package of the logic processing. Finally, the processing result is returned and transmitted as a whole through the service layer of the monolithic application to realize the monolithic processing of multiple services.

[0034] Figure 2 Micro refers to multiple microservices. Multiple microservices implement differentiated processing of different business functions by calling different business layers (ServiceA and ServiceB). The middle part is forwarded and transmitted through Fegin to achieve service-oriented processing.

[0035] See also Figures 1 to 3 The present invention provides a modular-based code compatibility method, which specifically includes the following steps:

[0036] first step

[0037] Disassemble the application software system from the perspective of business and technical implementation, and define separate engineering codes.

[0038] Step 2

[0039] Define an interface project, which only contains interface definitions and is only the interface called between the projects disassembled in the first step.

[0040] Step 3

[0041] Define a sub-project that inherits the interface project in the second step. If the software architecture of the application software system is a monolithic architecture, this sub-project is implemented by introducing the jar package when implementing the interface project; if the software architecture of the application software system is a microservice form of spring cloud alibaba, it is implemented by calling openfeign. If the software architecture of the application software system is in other ways, such as dubbo microservice calls, it can be implemented using dubbo's calling method.

[0042] Step 4

[0043] Define a shell project that only includes configuration and startup, and has no other functional logic. If it is in a single form, only define one shell project, introduce the interface project in the second step and the jar package project in the third step; if it is in the form of microservices, define multiple shell projects, and introduce the interface project in the second step and the spring cloudalibaba package or dubbo implementation package in the third step.

[0044] The code compatibility method of the present invention realizes a set of codes without duplication of codes by combining two architectural styles, the monolithic and the microservice. The business functions of the application system are split from the business logic through the DDD design method, and the code engineering is created according to the split functional units. The deployment requirements of the microservice are created from the physical structure. In combination with the concept of interface-oriented programming, the calling interface of each engineering package is abstracted out of the interface layer, and then the interface implementation engineering package is generated through different integration forms, one is the sub-project of the jar package, and the other is the sub-project called by the microservice.

[0045] There is no additional workload in code writing. The core code is split into multiple projects according to the business and technology. The project that undertakes the service orchestration function will generate a shell project with only the startup class and various configurations, so that microservices can be generated; if it is a single deployment method, all projects are integrated into a shell project with only the startup class and various configurations, and released to the outside in the form of a single package.

[0046] By defining interfaces and sub-project inheritance, different docking methods can be extended, which can be feign calls of microservices, single jar references, or extended to asynchronous calls of MQ.

[0047] At the same time, the problem of mutual dependence of each project jar package is solved. As a single method, multiple jar packages often depend on each other. The present invention defines an interface layer, and each project jar package avoids directly referencing the project jar by referencing the interface abstract layer.

[0048] In another embodiment, the present invention further provides a modular-based code compatibility system, which includes:

[0049] A disassembly module is used to disassemble the code logic of the application software system into a business function module and a technical component function module, define the business function module as a separate project, and define the technical component function module as a separate project;

[0050] A definition module is used to define an interface project that calls a separate project. The interface project only includes interface definitions.

[0051] The definition module is also used to define a sub-project that inherits the interface project, and the sub-project uses a jar package calling method, a feign calling method, or a dubbo package calling method to call the interface project;

[0052] A generation module is used to generate one or more shell projects and integrate the interface project and the sub-project into the shell project.

[0053] In another embodiment, the present invention further provides a computer-readable medium storing a computer program for executing the above method.

[0054] The present invention is based on a modular design of a set of codes to implement a solution that can be deployed in microservices and monomers. Monoliths and microservices are two different architectural styles. Microservices are disassembled from a business perspective based on the monomer, and each service has its own communication method, so that a set of codes is compatible with two architectural styles.

[0055] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification.

[0056] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify and vary the above embodiments within the scope of the present invention.

Claims

1. A modular-based code compatibility method, characterized in that: The method comprises: S1. Decompose the code logic of the application software system into a business function module and a technical component function module, define the business function module as a separate project, and define the technical component function module as a separate project; S2, define an interface project that calls the separate project in step S1, and the interface project only includes interface definition; S3. Define a sub-project that inherits the interface project in step S2. The sub-project uses the jar package calling method, the feign calling method, or the dubbo package calling method to call the interface project in step S1. S4. Generate one or more shell projects, and integrate the interface project in step S2 and the sub-project in step S3 into the shell project.

2. The modular-based code compatibility method according to claim 1, characterized in that: The shell project consists of configuration function logic and startup function logic.

3. The modular-based code compatibility method according to claim 1, characterized in that: S3. Define a sub-project that inherits the interface project in step S2. The sub-project uses the jar package calling method, the feign calling method, or the dubbo package calling method to call the interface project in step S1. Specifically, it includes: Define a sub-project that inherits the interface project in step S2. When the software architecture of the application software system is a monolithic architecture, the sub-project calls the interface project using a jar package call. When the software architecture of the application software system is the spring cloud alibaba microservice architecture, the sub-project uses the openfeign calling method to call the interface project; When the software architecture of the application software system is the dubbo microservice architecture, the sub-project uses the dubbo package calling method to call the interface project.

4. The modular-based code compatibility method according to claim 1, characterized in that: S4, generating one or more shell projects, integrating the interface project in step S2 and the sub-project in step S3 into the shell project, specifically including: When the software architecture of the application software system is a monolithic architecture, a shell project is generated, and the interface project in step S2 and the jar package in step S3 are integrated into the shell project; When the software architecture of the application software system is a microservice architecture, multiple shell projects are generated, and the interface project in step S2 and the spring cloud alibaba package or dubbo package in step S3 are integrated into the shell project.

5. The modular-based code compatibility method according to claim 1, characterized in that: The sub-project also uses MQ asynchronous calling method.

6. A modular-based code compatibility system, characterized in that: These include, A disassembly module is used to disassemble the code logic of the application software system into a business function module and a technical component function module, define the business function module as a separate project, and define the technical component function module as a separate project; A definition module is used to define an interface project that calls a separate project. The interface project only includes interface definitions. The definition module is also used to define a sub-project that inherits the interface project, and the sub-project uses a jar package calling method, a feign calling method, or a dubbo package calling method to call the interface project; A generation module is used to generate one or more shell projects and integrate the interface project and the sub-project into the shell project.

7. A computer-readable medium, characterized in that The readable medium stores a computer program for executing the method according to any one of claims 1 to 5.