Architecture Model and example of plug-in Design

Source: Internet
Author: User
Plug-in design has been very popular in recent years, and eclipse has played an important role. When it comes to plug-in design, you can't help but think of Eclipse. In fact, plug-in design is not a new thing, as early as decades ago. X server is designed based on plug-ins. In addition to its core functions, all its extension functions and device drivers are added as plug-ins. Plug-in-based design has many advantages: the extension function is removed from the framework, which reduces the complexity of the framework and makes it easier to implement the Framework. The extended functions are coupled with the framework in a very loose way, the two are still connected to Huai Yu, which is far from the rest of the head of the muscle 9 Yong mei yu Xie Xiaoyu, Ma Taolu, tomb delta, yi Huang Yi I A yi Wei? Lt;/font> plug-in-based design is not mysterious. On the contrary, it is simpler and easier to understand than a group of mud designs. Various plug-in-based architectures have their own characteristics, but their models are similar in terms of the overall architecture. Here we will introduce a simple model and provide several examples to inspire new users. 1. Application of basic architecture plug-in Design Program , Which can be basically used for representation. Of course, this figure is a high-level representation, and the actual design will be more complex. We don't have to make it so complicated to elaborate on it for convenience. An application consists of four parts: Application Framework, plug-in interface, plug-in, and public function library. Application Framework Responsible for the overall operation of the application. It is clear about the entire process, but does not know what to do for each process. It calls some plug-ins when appropriate to complete real functions. Plug-in Interface It is a protocol, which may be described by IDL, a header file, or a text description. The plug-in is implemented according to this Protocol and can be added to the application. Of course, for complex systems, there may be multiple plug-in interfaces with independent functions. Plug-ins Is the entity that completes the actual function and implements the required plug-in interface. Although what is implemented and how it is implemented, it is completely the plug-in's own freedom. In actual situations, there are still some restrictions, because the plug-in interface itself may be a limitation. For example, plug-ins that implement the compilation function naturally cannot implement a chat function plug-in. Common function library Is a group of functions or classes that can be called by application frameworks and plug-ins. It is usually an independent dynamic library (DLL ). The application framework itself is public, yes Code A Method of reuse. But not all reusable code can be placed in the framework, especially the public code used by the plug-in, which will cause the plug-in to depend on the framework. It is a good method to extract the public code into an independent library. In addition, it is worth noting that the plug-in interface is used. There are usually two types of plug-in Interfaces: General Plug-in Interface : This type of plug-in interface is common. You cannot see the functions of this plug-in from the interface functions. Its interface functions usually have these functions: init: used to initialize the plug-in, which is usually called when the plug-in is loaded. Deinit: used for anti-initialization of the plug-in, which is usually called when the plug-in is uninstalled. Run: Start the plug-in. Stop: Stop the plug-in. The plug-in determines the functions to be inserted into the init function. It calls the functions in the public function library and registers itself to a certain position in the framework. Dedicated plug-in Interface : This type of plug-in interface is dedicated. When you see its interface function descriptions, you can get a general idea of its functions. The configuration information is usually used to add plug-ins. The configuration information can be a registry or a configuration file. You can also dynamically register the plug-in or place it in the specified location. Here are some examples: 2. desktop design has completed the design and implementation of the desktop module recently. According to past experience, the desktop module is usually the most changing module, and spec is constantly adjusting the effect. Different customers require a personalized desktop until the product is quickly released, the desktop spec is constantly being modified. In addition, in the smart phone, desktop has a special position. Many things may be inserted into the desktop. Desktop is not only a hodgedge of various functions, but also a transfer station for some system messages. This task is tricky, so be careful when designing it. The first thought was to adopt plug-in design to separate peripheral functions and simplify the implementation of the framework as much as possible. Plug-ins : Each minimum functional unit is a plug-in, which can be visible, unavailable, or dynamically changed. Such as time, battery power, network connection, signal strength, new events (such as SMS, MMS, Emal, alarm, and missed calls), application shortcuts, left and right buttons, and other functional units for processing system events. Each plug-in is described using a. desktop, which complies with the freeyuntop.org standard. Desktop framework Includes the status bar, Start Menu, Operation bar, desktop area, event manager, and topic manager. The status bar, Start Menu, Operation bar, desktop area, and event manager are containers that hold various plug-ins. For visible plug-ins, you can have your own representation, or use a common representation. Common function library : Abstract classes, helper classes for implementing plug-ins, and other classes that may be public. Plug-in Interface : For invisible plug-ins, the event processing function is required. Visible plug-ins also require the rendering function. 3. Simulator Design a colleague is responsible for designing a PC simulation environment for another platform. At my suggestion, he adjusted the architecture. The adjusted architecture is very simple and can be considered as a plug-in design. It consists of the following parts: Application Framework : Responsible for the basic functions of the simulator, such as analog keyboard and display devices and skin replacement functions. Plug-ins : It is the simulated platform, such as microwindow and the corresponding mobile app. This method makes sense even though only one plug-in is often run during runtime. If you want to change to MiniGUI or another platform, the simulator does not need to be modified. Common function library : Some information and callback functions are initialized by the application framework and then called by the plug-in (microwindow). The plug-in uses it to implement drivers such as display and input. Plug-in Interface : Such as starting and stopping a simulated platform. 4. gimpgimp is a powerful graphic image editor. It is a typical plug-in-based design. It has been introduced as a plug-in design example in Unix programming art. Application Framework : Gui Plug-ins : Complete various conversion and processing functions of the image, such as blur, decimal spots, and color adjustment. Common function library : Put it in libgimp. So. Plug-in Interface : Anyone interested in gimp can go to the official website to read more documents.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.