Designing web-based plugin systems correctly so they don't waste as many resources?

Posted by Xeoncross on Programmers See other posts from Programmers or by Xeoncross
Published on 2012-01-20T18:14:39Z Indexed on 2012/11/27 17:19 UTC
Read the original article Hit count: 274

Many CMS systems which rely on third parties for much of their code often build "plugin" or "hooks" systems to make it easy for developers to modify the codebase's actions without editing the core files.

This usually means an Observer or Event design pattern.

However, when you look at systems like wordpress you see that on every page they load some kind of bootstrap file from each of the plugin's folders to see if that plugin will need to run that request. Its this poor design that causes systems like wordpress to spend many extra MB's of memory loading and parsing unneeded items each page.

Are there alternative ways to do this? I'm looking for ideas in building my own.

For example, Is there a way to load all this once and then cache the results so that your system knows how to lazy-load plugins? In other words, the system loads a configuration file that specifies all the events that plugin wishes to tie into and then saves it for future requests?

If that also performs poorly, then perhaps there is a special file-structure that could be used to make educated guesses about when certain plugins are unneeded to fullfil the request.

Any ideas?

If anyone wants an example of the "plugin" concept you can find one here.

© Programmers or respective owner

Related posts about php

Related posts about design-patterns