如果您想创建模块化的应用程序,最好的资源是什么? [英] What are the best resources if you wanted to create an application with modularization?

查看:17
本文介绍了如果您想创建模块化的应用程序,最好的资源是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我对 Drupal、Wordpress 和 Salesforce 等较新的网络平台/应用程序的分析中,他们中的许多人基于模块化的概念创建了他们的软件:开发人员可以在其中创建新的扩展程序和应用程序,而无需更改由主要开发人员维护的核心"系统.特别是,我知道 Drupal 使用了一个钩子"系统,但我对实现它的引擎或设计知之甚少.

In my analysis of the newer web platforms/applications, such as Drupal, Wordpress, and Salesforce, many of them create their software based on the concept of modularization: Where developers can create new extensions and applications without needing to change code in the "core" system maintained by the lead developers. In particular, I know Drupal uses a "hook" system, but I don't know much about the engine or design that implements it.

如果您要走上创建应用程序的道路,并且想要一个允许模块化的系统,您从哪里开始?这是每个人都知道的特定设计模式吗?是否有该范式倾向于订阅的手册?他们是否有任何网站从头开始讨论这种类型的开发?

If you were to go down a path of creating an application and you wanted a system that allowed for modularization, where do you start? Is this a particular design pattern that everyone knows about? Is there a handbook that this paradigm tends to subscribe to? Are their any websites that discuss this type of development from the ground-up?

我知道有些人直接指向 OOP,但这似乎完全不同.

I know some people point directly to OOP, but that doesn't seem to be the same thing, entirely.

我计划的这个特定系统更倾向于 Salesforce 之类的东西,但它不是 CRM 系统.

This particular system I'm planning leans more towards something like Salesforce, but it is not a CRM system.

为了这个问题,请忽略购买与构建的论点,因为这种考虑已经在进行中.现在,我正在研究构建方面.

For the sake of the question, please ignore the Buy vs. Build argument, as that consideration is already in the works. Right now, I'm researching the build aspect.

推荐答案

这里有两种方法,采用哪种方法取决于您的软件将如何运行.

There are two ways to go around here, which one to take depends on how will your software behave.

一种方法是插件 route,人们可以在此安装新代码到应用程序中修改相关方面.这条路线要求您的应用程序是可安装的,而不仅仅是作为服务提供(否则您安装并检查第三方发送的代码,这是一场噩梦).

One way is the plugin route, where people can install new code into the application modifying the relevant aspects. This route demands your application is installable and not only offered as a service (or else that you install and review code sent in by third parties, a nightmare).

另一种方法是提供一个 API,它可以被相关方调用并使应用程序将控制权转移到位于其他地方的代码(如 Facebook 应用程序)或使应用程序按照 API 命令启用开发人员(如 Google 地图)执行操作.

The other way is to offer an API, which can be called by the relevant parties and make the application transfer control to code located elsewhere (a la Facebook apps) or make the application to do as the API commands enable the developer (a la Google Maps).

即使机制各不相同,实际实现方式也各不相同,但无论如何,您都必须定义

Even though the mechanisms vary and how to actually implement them differ, you have to, in any case, define

  • 我会给用户什么自由?
  • 我将为程序员提供哪些服务来定制应用程序?

还有最重要的一点:

  • 如何在我的代码中启用此功能,同时保持安全和稳健.这通常是通过对代码进行沙箱化、验证输入并可能向用户提供有限的功能来完成的.

在这种情况下,钩子是代码中的预定义位置,它调用所有已注册插件的钩子函数,如果定义,则修改应用程序的标准行为.例如,如果你有一个渲染背景的函数,你可以有

In this context, hooks are predefined places in the code that call all the registered plugins' hook function, if defined, modifying the standard behavior of the application. For example, if you have a function that renders a background you can have

function renderBackground() {
    foreach (Plugin p in getRegisteredPlugins()) {
        if (p.rendersBackground) p.renderBackground();
    }
    //Standard background code if nothing got executed (or it still runs, 
    //according to needs)
}

在这种情况下,您有插件可以实现的renderBackground"挂钩来更改背景.

In this case you have the 'renderBackground' hook that plugins can implement to change the background.

以 API 的方式,用户应用程序将调用您的服务来获取背景渲染

In an API way, the user application would call your service to get the background rendered

//other code
Background b = Salesforce2.AjaxRequest('getBackground',RGB(255,10,0));
//the app now has the result of calling you

这也都与好莱坞原则有关,这是一个很好的应用,但有时就是不切实际.

This is all also related to the Hollywood principle, which is a good thing to apply, but sometimes it's just not practical.

这篇关于如果您想创建模块化的应用程序,最好的资源是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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