我们如何在面向对象编程中创建插件/扩展?
软件如何允许开发人员在其核心之上制作插件/扩展?这与面向对象编程有什么关系?也许有继承或接口?应该使用什么样的设计模式?
例如,增强 firefox 的 firefox 扩展、wordpress 扩展等。这些系统在安装后会“识别”插件并运行良好,在某些情况下它们会执行安全检查、依赖项等。
有人愿意解释一下吗?
How does software allow developers to make a plugin / extensions on top of its core? How is that related to object oriented programming? maybe with inheritance or interfaces? What kind of design pattern should one use?
For example, firefox extensions that enhance firefox, wordpress extensions, etc. Those systems sort of "recognize" plugins after being installed and work well and in some cases they perform safety checking, dependencies, and the like.
Anyone care to shed light on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Firefox 等实际应用程序中的插件模型可能比一般情况更复杂。一般来说,您定义插件应该实现的一些接口,并在您的插件中实现它,就是这样。
现代框架包含插件开发工具,例如 .NET 中的 MEF、Java 中的 mojo 等。
Plugin models in real applications like firefox may be more complex than they are in general. In general you define some interface that a plugin should implement, and implement it in your plugins, that's it.
Modern frameworks contain plugin development facilities like MEF in .NET, mojo in Java, etc.
Java 通过其 SPI(服务提供者接口)支持基本的插件机制。主要机制围绕新提供者的发现和绑定。下面两篇文章将帮助您入门
有一些开源框架比 JDK 提供的功能更强大
但是OSGi 在我看来是所有插件框架的标准和之母。
Java supports a basic plug-in mechanism through its SPI (Service Provider Interface). The main mechanism revolves around discovery and binding of the new provider. Below two articles will get you started
There are open source frameworks that are more powerful than provided by JDK
But OSGi is the standard and mother of all plugin frameworks in my opinion.