Right now, our code is gradually getting cleaner and we do have hints of separation here and there, but we have decided we need to focus on developing our model appropriately. However, rather than try and refactor the awful database design, we want to build a clean object layer (the model) on top, have tests for it, and then drive everything through that layer so that later we are in a better position to fix the database. That leads to an interesting design problem.
One primary design goal is, as much as possible, only expose object responsibilities, not data. We're considering either using a ORM or the phrasebook pattern. Because our database is designed so poorly, while I do like ORMs, I'm thinking that perhaps a phrasebook would be a better way to go. That being said, ORMs can save a lot of agony, if done properly (and I find 'em quicker to implement.)
With an ORM, it should be easy to add custom, hand-written SQL for the numerous cases where our bad database design creates an obstacle for an ORM. Having used Class::DBI in the past, it seems like a good fit for this. Not having used DBIx::Class, I can't comment on it, but at least one of our programmers has said his experience with it suggests that there's a large performance hit on the initial loading of large schemas. Because this code is running as CGI and not mod_perl (and is in no shape to be converted), we can't afford that performance hit. I also hear great things about Rose::DB::Object, but I also haven't played with that yet.
So given the desire to create an model of a poorly designed database and the need to add custom SQL in various bits of it (and in some places, even post-processing with Perl to get reasonable data), what approach would you take? ORM (which one), phrasebook, or something else altogether? I realize much of this is vague and I'll be researching myself, but suggestions welcome.
The database is MySQL 4.1.19.
Cheers,
Ovid
New address of my CGI Course.
In reply to Creating a model of a bad database by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |