Web 应用程序中的插件架构(示例或代码片段?) [英] Plugin Architecture in Web Apps (Examples or Code Snippets?)

查看:22
本文介绍了Web 应用程序中的插件架构(示例或代码片段?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习开发一个高度可扩展且可通过插件自定义以启用禁用功能的 Web 应用程序(最好是 NodeJS/MongoDB,尽管我之前使用过 PHP 和 Python).

I am trying to learn to develop a web application (preferably NodeJS/MongoDB, although I used PHP and Python before) that is highly extensible and customizable via plugins to enable disabled functionality.

一种可能的选择是使用带有挂钩的 Wordpress 插件和小部件挂钩,但它缺乏适当的视图和逻辑代码分离.这仍然是一种可供学习的选择.还有其他选择吗?

One possible option is to use Wordpress with hooks for plugins and widgets to hook into, its however lacking proper separation of view and logic code. That remains to be one option to learn from. Are there any other options?

你有任何我可以学习的代码片段或示例应用程序吗?语言或框架不是那么重要,我大概可以大致了解背后的概念

Do you have any code snippets or example application I can learn from? Language or framework is not so important, I could probably roughly make out the concept behind

推荐答案

一个好的插件架构很难从头开始实现,但它有自己的回报.它通过本地化复杂性使软件灵活且易于维护.它需要的首要技能是编写松散耦合代码的能力.这需要对多态性、德墨忒尔定律和相关的好莱坞原则.

A good plugin architecture is difficult to achieve from scratch, but offers its own rewards. It makes the software flexible and simple to maintain by localising complexity. The foremost skill it requires is the ability to write loosely coupled code. This demands a very firm grasp of polymorphism, Demeter's Law and the related Hollywood principle.

我建议您先熟悉这些,然后再了解以下设计模式,这将大大降低难度:

I recommend that you initially gain a good familiarity with those, then the following design patterns, which will reduce the difficult significantly :

  • Command Pattern : Gives Plugin Modules a consistent entry point, allowing them to be readily swapped in and out, a Web Based example from IBM.
  • Memento : Capture, hold and externalise state without violating encapsulation, allows plugins to be configured by the container.
  • Call Back : Allows the Plugin Modules to access 'services' from the container/environment.
  • Dependency Injection : A way to loosen the coupling of Plugin Modules from their environment.
  • Abstract Factory Pattern : Installing and instantiating the Plugin in the environment.
  • Builder Pattern : Required for any non trivial plugin architecture where Plugin Modules are dependent on each other.

一旦你掌握了这些,就研究一些现有的插件框架实现和架构,看看它们是如何被使用的.Apache 在 StrutsGeronimo 自定义服务器程序集Tomcat JNDI 资源;还有 Eclipse 插件框架.

Once you grasp those, study some of the existing Plugin Framework implementations and architectures to see how they've been used. Apache have several in Struts, Geronimo custom server assemblies and Tomcat JNDI Resources; Also the Eclipse plugin framework.

这篇关于Web 应用程序中的插件架构(示例或代码片段?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆