From: Eloi G. <el...@re...> - 2004-04-14 21:06:36
|
Right now there's 2 schools of thought on this, Mike. The Item-Manager module style came about because we wanted a way for new module developers to (1) be able to rapidly develop applications, and (2) decrease the memory usage of phpWebsite, because many module classes were loaded/kept in memory on each pageview. If all of the modules used the same base class functions (PHPWS_Manager & PHPWS_Item), then less code would have to be kept in memory. Reason #1 is invalid right now because PHPWS_Manager & PHPWS_Item are largely undocumented & uncommented. Reason #2 is partially obsolete because with version 0.9-2, module classes stopped being automatically loaded by the core, freeing module developers to more finely tune which classes get loaded when. I said *partially* because it still has a benefit for modules that operate on the same page as others. The Item-Manager module style also has some limitations -- one being that you can only take your module's capabilities so far before you have to start writing extra code to make the base classes do stuff that they're not designed to do, 'cause Item&Manager aren't just reuseable code -- it's an entire framework. The other problem is that when you have an additional level of middleware code, you also increase the execution time of the script. When that happens, the server can't handle as manu requests before it crashes. The other method of module writing is like Notes. If you need a class, you use one. You write the code to be fast and tight, doing only what *you* need it to do. You can optimize queries to reduce the workload on the database server. It's even easier to learn this way because either method requires you to learn how to use the Core classes, but you really don't ever have to look at Item or Manager if you don't want to. If you want to keep memory usage down, remember that include() and require() are your friends! If you're not using a piece of code, don't load it. Take a look at ArticleManager as a (non-definitive) example. Also, don't be afraid to unset() a variable after you're finished using it -- especially if it's using a lot of memory. Bottom line is -- you can decide for yourself which way to want to code the module. From your description it sounds so simple that it may not even need a class! You could most likely code the entire thing in /mod/yourmodule/index.php and not have your server deal with the overhead of creating a class. Geez, I kinda went off on a rant there, didn't I? -Eloi- Mike Potvin wrote: >Don, >I guess I'm not thinking in a very PHPWS-way yet :) Help me wrap my head >around this. This is how my module works: I have several links to the >module in various menus. Each link passes a different parameter (in this >case an author's name). The module selects rows from an sql database that >match that author's name and displays the results in a table. There is no >user interaction required (user or deity). What would my manager do? >Mike... > > > >>Regardless of how simple your module might be, making use of the >>Item/Manager system provides a lot of flexibility and code re-use. Even >>if I just had a single item with a single field (much like skeleton), I >>would still use a Manager. >> >>Don >> >> > > > > >------------------------------------------------------- >This SF.Net email is sponsored by: IBM Linux Tutorials >Free Linux tutorial presented by Daniel Robbins, President and CEO of >GenToo technologies. Learn everything from fundamentals to system >administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click >_______________________________________________ >Phpwebsite-developers mailing list >Php...@li... >https://lists.sourceforge.net/lists/listinfo/phpwebsite-developers > > > |