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

Have you considered an event/template driven approach. (This would work mostly for Changes the look and actions of a button) Then each 'module' could register a handler for certain events, and template could call certain events.

Like the header module might have DoEvent("DrawTitleBar") Then the engine could call all handlers associated with that event. Each 'module' could then add its own buttons and/or formating to the title bar by adding a handler to that event.

The template would then obviously need to handle these event calls, and transform button clicks into Event calls etc, and you would need some standard data format that each module would have access too.

I hope this helps or at least provides some spark of thought. Anyone have ideas/comments about my idea?
  • Comment on Re: Best way to 'add modules' to web app?

Replies are listed 'Best First'.
Re: Re: Best way to 'add modules' to web app?
by BUU (Prior) on Jul 06, 2003 at 04:44 UTC
    Thats a very interesting idea/concept, and one I had not though of before. I'll definately have to give it some thought. I'm not sure of how the users would register handles for an event though..
      Frankly i'm not either. I've been working on concepts for a Community site with many of the features of Everything, Slashcode, Forums, Blogs, and link databases all combined into one.

      With perl it shouldn't be too hard to have each module have a standard init function that is called when its installed/loaded. That init function could then call a sub giving it the event to handle and a reference to the sub to call. I'd also think that instead of passing events arguments, either pass it a hashref with the arguments in it, or just have one common hash that is used to communicate between events, and the board/forum system.

      Some problems would be, how to handle multiple occurences of handlers...call them all? or let them overpower the original in some way? Maybe that could be one of the options for the function to set handlers. So some handlers are used in addition to the current one, and some replace the original. It would me anyone making modules needs to play nice, but thats true anyway. You could also run the modules in a Safe compartment to control what access they do have for some added security.

      I look forward to seeing what you do come up with!