Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

subclasssing vs using

by chorg (Monk)
on Apr 19, 2001 at 17:58 UTC ( [id://73817]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://73817]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (1)
As of 2024-04-24 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found