chorg has asked for the wisdom of the Perl Monks concerning the following question:

Hello all

I have a web based application that I want to code. I will use CGI.pm, but I want to package all the code into modules (of course) My decision is to either subclass CGI.pm and add the new methods, or
use CGI; in my module. Which is the better approach?
_______________________________________________
"Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."

Replies are listed 'Best First'.
(tye)Re: subclasssing vs using
by tye (Sage) on Apr 19, 2001 at 19:06 UTC

    Subclassing (inheritance) should only be done to classes (modules) that were designed to be subclassed. CGI.pm was not really designed for that so I would strongly discourage doing that.

    Besides, inheritance would be my last choice for incorporating features from another module into my module. Working with inheritance (at least implementation inheritance, which is really the only inheritance supported by Perl) is like working with big sheets of two-sided duct tape: Sure, you can stick things together really well, but it is just too easy to end up with too many things stuck too tightly together such that you can't work with anything anymore. (:

            - tye (but my friends call me "Tye")
Re: subclasssing vs using
by Masem (Monsignor) on Apr 19, 2001 at 18:02 UTC
    Well, I think it's more semantics; are you trying to overload some of the functions of CGI, or are you mearly trying to use CGI and providing all your own functions? In the former case, you'll definitely want to subclass CGI, but otherwise, I'd stick to 'use'.
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain