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

查看:83
本文介绍了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

推荐答案

一个好的插件架构很难从头开始实现,但是却提供了自己的回报.通过局部化复杂性,它使软件变得灵活且易于维护.它需要的最重要的技能是能够编写松散耦合的代码.这就需要非常牢固地掌握多态性, Demeter定律和相关的

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 :

  • 命令模式:为插件模块提供一致的入口点,从而可以方便地交换它们然后, IBM的基于Web的示例.
  • Memento :在不违反封装的情况下捕获,保持和外部化状态,允许通过以下方式配置插件容器.
  • 回叫:允许插件模块从容器/环境.
  • 依赖注入:一种使插件模块与环境耦合的方法.
  • li>
  • 抽象工厂模式:在环境中安装和实例化插件.
  • 构建器模式:对于其中插件模块相互依赖的任何非琐碎的插件体系结构都是必需的
  • 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.

一旦掌握了这些知识,请研究一些现有的Plugin Framework实现和体系结构,以了解如何使用它们. Apache在 Struts 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天全站免登陆