SPUG: OO Perl conundrum

Richard Anderson Richard.Anderson at raycosoft.com
Mon Jun 11 17:45:50 CDT 2001

I recently loaded an upgrade to HTTP::WebTest to CPAN, and promptly got an
interesting change request from a gentleman named Thomas Ayles (actually, a
submittal of the code for a complete revision of the module).
(HTTP::WebTest is a module that fetched URLs, runs tests on the returned
page and generates a detailed test report.)

Thomas's idea, which is good, is to define a namespace,
HTTP::WebTest::Plugins, to hold plugin subroutines that run additional tests
on the page.  Then coderefs to the subroutines are passed to HTTP::WebTest,
which passed the fetched page to the subroutine for testing.  Thomas also
defines a class HTTP::WebTest::PluginHelper to encapsulate the report

My concern is about Thomas's use of the package and use statements.  The
structure of the new HTTP::WebTest class looks like this:

package HTTP::WebTest;
    package PluginHelper;
   package Plugins;
   use HTTP::WebTest;

This seems like a fairly non-standard use of OO Perl.  Would this be better
done by subclassing HTTP::WebTest and making PluginHelper and Plugins
subclasses of the new subclass be better? Or is there some simpler approach?


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/

More information about the spug-list mailing list