Build a plug-in Application Framework (I)-Opening

Source: Internet
Author: User
Plug-in applications Program Everyone should be familiar with it. I remember a very popular MP3 player winmap a long time ago. It was the first plug-in-mode application I knew in my memory, you can use the plug-in Manager to insert a lot of music effects, skins, and even display panels of lyrics. Next we can see that Photoshop uses the plug-in mode to manage the lens. Finally, we found that as long as a large application basically uses a plug-in framework, let's take the most commonly used tools, such as Visual Studio, office, Delphi, and eclipse. Eclipse has brought the plug-in mode into play, because it is open-source, so many enthusiasts have developed plug-ins that are overwhelming.

Why is a plug-in application framework used? My answer is his unlimited imagination for app function expansion. An application, no matter how much market research you have done in the early stage and how perfect the demand analysis is, you just want to meet the expectations of some people, you only cater to some people's expectations, or some people's expectations at a certain time. So after the program is released, you still have the opportunity to provide new functions without having to re-release the program. People can also develop new functions to meet their own needs according to their own needs, as far as I know, many software companies are dedicated to developing plug-ins to make money. It's so amazing. Why not?

Let's look at some common applications that provide plug-in mode to implement plug-in functions. According to my experience, Visual Studio and office are actually automated programs, and a set of interfaces are provided through COM. Developers can use these interfaces to develop com-based plug-ins. After the plug-ins are developed, register the COM component. In Visual Studio, you can use the add-in Manager to choose whether to enable the plug-in. However, office seems to save this step. Once you register the Office plug-in, the Office application automatically loads the plug-in when it starts. Com seems to be the most favored by Microsoft, because COM is a binary reuse standard, users can use most popular languages to develop plug-ins. Of course, you can also use other methods, such as common DLL, but this is narrow for developers, because the internal structure of the DLL of various manufacturers is different, the DLL structure developed by VC is different from that developed by Borland C ++ builder. A dedicated tool is required for conversion. Now, there is another way to use the DOTNET assembly. The advantage of using DOTNET is that the development is simple and the use is also simple (registration is not required ), in addition, you can also enable developers to use various languages for plug-in development through COM interoperability. Of course, developing with DOTNET is the simplest, saving a lot of intermediate processes.

In fact, the plug-ins developed in the above three methods are ultimately hosted in the DLL, from which we can see some clues. Why is DLL used? Although the DLL is also in PE format, it cannot be run independently. Generally, it is loaded to the application's memory space at runtime. The plug-in mode utilizes this point. A plug-in is not part of an application. It exists independently in binary mode, and the user determines whether to use it.

Then how does the plug-in interact with the application? First, you must have a contract. The application must declare which functions can be used by the plug-in and which conditions can be used as my plug-in. Second, applications do not rely on plug-ins. That is to say, I can run well without your plug-ins. Once again, the application must have a policy to obtain the location where the plug-in exists. For example, Visual Studio uses the registry. Finally, the application can dynamically load the plug-in some way.

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.