Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the best resources if you wanted to create an application with modularization? [closed]

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?

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

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.

like image 791
Randy Burgess Avatar asked Mar 02 '23 02:03

Randy Burgess


2 Answers

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).

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

  • What freedom will I let the users have?
  • What services will I offer for programmers to customize the application?

and the most important thing:

  • How to enable this in my code while remaining secure and robust. This is usually done by sandboxing the code, validating inputs and potentially offering limited capabilities to the users.

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)
}

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

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.

like image 192
Vinko Vrsalovic Avatar answered Mar 05 '23 14:03

Vinko Vrsalovic


The Plugin pattern from P of EAA is probably what you are after. Create a public interface for your service to which plugins (modules) can integrate to ad-hoc at runtime.

like image 27
Eran Galperin Avatar answered Mar 05 '23 14:03

Eran Galperin