http://www.perlmonks.org?node_id=271636


in reply to Best way to 'add modules' to web app?

It seems to me that if you write your system with good object-oriented technique, you shouldn't have a problem allowing the extension of functionality, regardless of the planning.

Keep in mind I know nothing about the specifics, but let's say, for example, you have a Forum::Format module. This module has the methods:

$f->formatPost() $f->outputPost()
You can also define the abstract or stub methods:
$f->preFormatPost() $f->postFormatPost() $f->preOutputPost() $f->postOutputPost()
If some other class is calling the  $f->formatPost() method, make sure it calls $f->preFormatPost() before and $f->postFormatPost() after. Even if the abstract versions of these classes do nothing, future module writers can have their classes inherit from Forum::Format and override these methods or even rewrite your Forum::Format module without changing a thing except for these two methods. I realize your system may be a bit more complex than this and having future writers rewrite one of your base classes is a bad idea, but the idea of leaving "hooks" for pre/post formatting (or other actions) is still sound.

Additionally, anything you do inside the Format method could call other methods that can be overridden. So if, within Format, you call $f->modifyHTML($text) or something similar, that method can be overridden to modify HTML differently in a child of the Forum::Format class.