The essence of the plug-in is to expand and enhance the software functions without modifying the program entity (Platform). When the plug-in interface is published, any company or individual can create their own plug-ins to solve some operational inconvenience or add new features, that is, to achieve the true sense of"
Plug-and-play
"
Software development. The Platform + plug-in software structure divides a target software to be developed into two parts: the main body or main framework of the program, which can be defined as a platform, and the other part is a function extension or supplementary module, can be defined as a plug-in.
Before software development, whether or not to use the Platform + plug-in structure for software development depends on the specific software requirements, but generally speaking, using the Platform + plug-in structure for software design will add new vitality to the developed software. After determining the software structure of the Platform + plug-in, it is necessary to analyze which functions are completed by the subject, that is, the basic functions of the platform, and which functions are completed by the plug-in, that is, the plug-in functions to be extended. The functions completed by the platform should be the core and foundation of a software system. These basic functions can be used by users or plug-ins, that is, the basic functions of the platform can be divided into two parts, kernel functions and plug-in processing functions.
The kernel function of the platform is an important function of the entire software. Most of the functions of a software are completed by the kernel function. The plug-in processing function of the platform is used to expand the platform and Management plug-ins. It provides a standard platform extension interface for the plug-in platform to manipulate the platform and communicate with the plug-ins.
The function completed by the plug-in is to extend and supplement the platform function. Generally, the plug-in completes the serialization function, for example, the filter plug-in of Photoshop completes the special effect processing on the image, these functions have some commonalities. They can be centrally managed and can define standard plug-in interfaces.
To implement the software design of the Platform + plug-in structure, two standard interfaces must be defined. One is the platform extension interface implemented by the platform and the other is the plug-in interface implemented by the plug-in. It should be noted that the platform extension interface is fully implemented by the platform. The plug-in is only called and used. The plug-in interface is fully implemented by the plug-in, and the platform is only called and used.
The Platform extension interface enables one-way communication between the plug-in and the platform. The plug-in obtains various resources and data of the main framework through the platform extension interface, including various system handles, internal program data, and memory allocation. The plug-in interface provides one-way communication between the platform and the plug-in. The Platform calls the functions implemented by the plug-in interface to read plug-in data and process data.
The Platform Plug-in processing functions include plug-in registration, management, and calling, as well as the function implementation of the platform extension interface. To register a plug-in, first search for installed plug-ins in the system according to a certain mechanism, then register the searched plug-ins on the platform, and generate a corresponding call mechanism on the platform, this includes menu options, toolbar, and internal calls. The plug-in management completes coordination between the plug-in and the platform, generates management information for each plug-in on the platform, and tracks the status of the plug-in. A plug-in call calls the functions implemented by each plug-in. Another part of the Platform Plug-in processing function is the specific implementation of the platform extension interface.
Plug-in software design steps include:
1. determine the basic functions and plug-ins of the platform to complete the serialization or expansion of functions;
2. Define platform extension interfaces and plug-in interfaces;
3. Complete the platform design, mainly the Platform Plug-in processing function;
4. Provide the plug-in developer with the main platform Program (code execution) and publish the platform extension interface and the interface to be implemented by the plug-in, which may include the Development SDK;
5. Plug-In developers develop plug-ins as required to implement plug-in interfaces. developers can use the provided main platform program test plug-ins;
6. The primary platform designer continues to complete the kernel functions of the primary platform, and can announce the addition of new primary platform extension interfaces and plug-in interfaces at any time;
7. Achieve a virtuous circle of steps 4-6, and the entire software system continues to evolve.
Advantages of Platform + plug-in software design:
1. Implement True Software Components
"
Plug-and-play
"
;
2. Integrate software at the binary level to reduce the trouble and time for software re-compilation and release;
3. It is able to achieve division of labor development of software modules, and can greatly absorb the advantages of others;
4. Better code hiding and protection of intellectual property rights.
Plug-in Interface
To develop an application that supports the plug-in function, you must solve one problem: how to correctly communicate with each other between the main program and the plug-in. In order to correctly communicate with each other between the main program and the plug-in, a set of communication standards should be established first. This communication standard is the interface, and the main program and plug-in can only communicate with each other through the established interfaces. In software development, an interface only defines a function and specifies the form of calling the function, but does not include the implementation of the function. Interfaces are essentially the call specification of software modules.
For applications that support plug-in development, generally, the interface is developed by the main program developer. If you want other developers to develop the relevant plug-ins, you only need to publish the relevant interfaces. The interface function is generally implemented by the plug-in side. Because the implementation of the plug-in also calls the main program function, the interface function may also be implemented by the main program. That is to say, the information flow between the main program and the plug-in may be two-way.
The interface call specification and function implementation are separated by one great advantage: although different plug-in developers have different implementations for the same interface, however, the calling methods for these plug-ins are the same in the main program. If you have interfaces implemented by the main program, you can use the same method to call the functions of the main program in different plug-ins. This greatly improves the flexibility of the application.
Program Structure and running mechanism
In the main program, the plug-in Management Section is used to manage the installation and deletion of plug-ins, and save the information of all installed plug-ins to appropriate places, such as to the registry or configuration file. When the main program starts, it is in the plug-in module according to the plug-in configuration information, and then obtains and saves the plug-in output function or pointer of the output class. If necessary, you can add interface elements, such as menus and toolbar buttons, to the main program. When you click the interface element associated with the plug-in the main program, the plug-in calls the function, use the plug-in information stored in the main function type to call the functions implemented in the plug-in call function. When calling the plug-in output function, you can also pass the interfaces implemented in the main program to the plug-in party.