Hardy Merrill wrote:
> What we did, before we knew about Perl OO, was to create > a database module subroutine that took care of the connection > to the database - all the scripts did to create a DBI > connection to the database was to call that subroutine without > any parameters. Using this method, we could change the paramters > of the connection in one place. > > This seems very similar to, and almost exactly the same as, your > method of subclassing the DBI, except we chose to use modules > with subroutines instead of subclassing the DBI using classes > and methods. > > I'm not knocking the OO approach to subclassing the DBI - in > fact I prefer that method - I just want to understand if/how it > is better than the modules/subroutines method, since it seems > as though you can accomplish the same goal of database > abstraction both ways. I don't think an OO approach is always the best one, despite what you may hear from all the OO zealots around today. I find that many people who "do OO" code worse in terms of data hiding and interface specification than people I know who coded procedurally 15 years ago. So there is no one answer. Perl, fortunately, gives us the choice. Typically I find that I DO use OO for this reason: With most of the interfaces I want to extend/enhance, there is data associated with those extensions -- not just functions/subroutines I need to add. OO subclassing addresses adding both data and methods better than procedural approaches IMHO. Perl tends to get a bad OO knock from people who never progressed beyond Perl4. I find it has some unique things that most OO languages lack that give it more power in some areas; e.g., ties and closures. Here's one Perl OO gem I like. I forget where I read it. One of the Perl things that drives lots of strict OO people wild is its weak typing; e.g., a scalar of digits may be treated as a string or a number, etc. In practice, I can't remember a case where this has bitten me. Maybe it does bite less experienced programmers, but for me (a lazy old programmer) it just saves writing and/or calling all those conversion functions. In one Perl OO piece, they sort of tongue in cheek touted this as an OO feature by saying Perl is "contextually polymorphic." I love that. 8-) -- Steve Sapovits Global Sports Interactive http://www.globalsports.com Work Email: [EMAIL PROTECTED] Home Email: [EMAIL PROTECTED] Work Phone: 610-491-7087 Cell Phone: 610-574-7706
