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

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

问题描述

在我对较新的 Web 平台/应用程序(例如 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.

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

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天全站免登陆