On Tue, Mar 29, 2005 at 04:37:06PM -0400, Jeff MacDonald wrote: > I guess I"m saying that in most C::A liturature it says the bonus is > code reuse and sharability, but i'm not sure how i should be coding > my stuff to take best advantage of it.
A lot of examples of code-reuse will depend on your needs. For example, I work at an agency with a lot of different departments with similar needs. So if I write a CGI::App to do, for example, file uploading/sharing, I can have: 1 Master subclass of CGI::Application that adds a few routines I'll use all the time (connection to my database of web meta-data, some parameter defaulting, my ties into Template::Toolkit) 1 Application module (that inherits from my master subclass) that is the web interface to my upload/download modules. 1 Upload/Download module that has no dependancy on CGI::Application, and is just called by my Application module. 10 instance scripts that pass a few parameters to the Application module. And then when one unit wants THEIR instance to behave just differently enough that it requires more than paramter changes: 1 subclass of my Application module that overrides the one or two runmodes or routines that are different. So I have 11 different units happy, with individualized apps for them, with minimal duplication of effort on my part. I have dozens of Application modules that inherit from my Master subclass. Each Application module has 1-20 instance scripts. Several Application modules (for example, the generic database interface BREAD module I have) have several commonly used subclasses that have only one or two routines in them...the other routines are inherited. This makes maintenance wonderful..once I have a change that I'm happy with (tested), I can change it in one module, and all instances and subclasses begin using that change. Also, by putting my "work" routines (the ones that arent' just web interfaces) into modules that aren't dependant on CGI::App, I can use them in other Application modules or even command line scripts. I have one non-applicaiton module that handles filename detainting and security checking, for example, along with making sure a desired path exists and has the proper permissions. I have another that handles all of the details necessary to send email. These are called from several otherwise unrelated application modules and utility scripts. I hope that helps a bit, feel free to ask more detailed questions. I used some OO terminology that I assume you have encountered, but ask if anything didn't make sense. -- SwiftOne / Brett Sanger [EMAIL PROTECTED] --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[email protected]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
