There are two ways to get around here, which one depends on how your software will work.
One way is the plugin route , where people can install new code in the application, changing the relevant aspects. This route requires that your application be installed and not only offered as a service (or you install and view the code sent by third parties, a nightmare).
Another way is to offer an API that can be called by the relevant parties and make the application transfer control code located elsewhere (a la Facebook applications), or make the application run, as the API commands allow the developer (a la Google Maps).
Despite the fact that the mechanisms differ and how to actually implement them, you must, in any case, determine
- What freedom can I allow users?
- What services do I offer programmers to configure the application?
and the most important thing:
- How to include this in my code while remaining safe and reliable. This is usually done using a sandbox of code, validating input, and potentially offering users limited options.
In this context, interceptors are predefined locations in the code that call all hook functions of registered plug-ins, if defined, changing the standard behavior of the application. For example, if you have a function that creates a background, you may have
function renderBackground() { foreach (Plugin p in getRegisteredPlugins()) { if (p.rendersBackground) p.renderBackground(); }
In this case, you have a renderBackground hook, which plugins can implement to change the background.
In the API, the user application will call your service to get the displayed background
All this is also connected with the Hollywood principle , which is very useful, but sometimes it is simply impractical.