By 'No Fear', I am suggesting that with sufficient decoupling of your application from the database, you can feel free to make changes to your application and to your database without being trapped by the terror of "what if we break the application that our entire company depends on?" Fear-based development is common, but clearly we recognize that what we really want is goal-based development. If we don't reach for goals because fear is holding us back, we've limited our company's opportunities.
Next month, I will be giving a talk at Portland Perl Mongers on this topic. A rough description of my talk is as follows:
use strict 'sql';
my $sql = 'SELECT * FROM that' and die "Don't do that!";
my $data = $sth->fetchrow_hashref and die "Or that!";
my $sql = 'SELECT this FROM that' and die "Still bad";
use base 'Class::DBI'; # much better
Many people misuse SQL. While some of the above can be fine for a sho
script, we should be careful about how SQL is used in a production env
C<use strict 'sql';> will detail why the above constructs can lead to
First, we'll show some examples of bad SQL and then move on to better
bad implementations (hint: I don't avoid C<&DBI::fetchrow_hashref> fo
performance reasons). We'll finish with a quick discussion of how obj
persistence modules can help lead us lead us out of the quagmire.
I'll primarily focus on C<Class::DBI> for the object persistence, but
touch on some of the other OO Persistence modules such as Tangram and
I'll also discuss what I think is a bit of a design issue with C<Class
(sorry Schwern!) and, by the end of the talk, you'll understand why I
Side note: despite the design issue I alluded to, C<Class::DBI> rocks
Bob says "check it out!"
In short, the thesis is that with proper abstraction of SQL, coupled with adequate tests (you didn't think I'd skip that, did you?), you can build more robust applications and have less worry about database changes, even dramatic ones. Anecdotes welcome! This post is essentially a request for your ideas, insights, experiences, etc, regarding this topic.
New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)