On Sat, 16 Jun 2001, Steve Howard wrote:

> Can someone point me to an example of a completely Object Oriented CGI
> script. The Perldoc examples are procedural, but there must be a good OOP
> example somewhere for me to tear apart and learn that technique from.

The CGI module itself is object-oriented.  Check out the CGI.pm web site:

http://stein.cshl.org/WWW/software/CGI/cgi_docs.html

But you can take this a step further and design your web application using
object-oriented techniques, such as Model-View-Controller.  A partner of
mine and I used something like this for some admin tools and search tools
for one of the Web Techniques sites.  Basically, we had one class that
modelled the data (using DBI underneath, but it was hidden by the class's
interface), another class that handled displaying the data (using CGI, but
again, the interface hid the details of CGI), and finally, a third top
level class that decided which screen to display by dynamically
dispatching methods based on a state variable to determine which screen
needed to be displayed. It may not have been strictly by the book MVC, but
it was definitely more interesting than just cranking out a CGI script,
and by separating the database stuff away from the display stuff, gave me
a lot more flexibility when I needed to modify certain parts of the
application without having to touch any of the actual class interfaces.

If you want to look at some another way of doing OO & component-oriented
web development, point your browser over to http://www.masonhq.com and
check out Mason, which is all Perl-based and very cool.  It also lets you
embed Perl code in HTML, but it's much more than that.

-- Brett
                                   http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
"A dirty mind is a joy forever."
-- Randy Kunkee

Reply via email to