2008/5/29 Jamie Lokier <[EMAIL PROTECTED]>: > Aaron Trevena wrote: >> it's the scattering of SQL all over the place that requires changing >> by hand when the schema is updated or code is refactored, etc. > > I'm curious, as a non-user of these classes - how does a schema change > not get reflected in how you have to call the classes? > > It seems to me that simple schema changes like adding a column or > changed field sizes don't require any change to SQL either - if you > wrote it sensibly. Similarly, classes which do some abstraction will > also have some schema changes which don't affect how you call the > classes, and some where you do have to update those calls all over > your code - same problem as Aaron says is avoided.
Adding a new field is a great deal easier, when you just specify that a class now has an additional attribute, now it can be accessed anywhere with 1 single line of code changed. You simple can't do that easily without writing your own db layer, and tracking metadata, in which case it's usually quicker to make use of an ORM or the type of tools that are used in/with ORM like SQL::Abstract, etc. > Seems to me that the main protection against this is to keep the > database calls in one module in your application - with that module's > API matching the logic of the application as cleanly as possible. This tends to result in an unwieldy and hard to maintain piece of code that attempts to do everything for everybody, I've seen several of these in almost every case, you'd be better off using an off-the-cpan module (not necessarily ORM, there are other options in DBIx:: namespace). > I'm not seeing how whether that app module uses some sQL, or various > abstraction classes, makes all that much difference to the work > involved when schema is changed. But I'm sure it does. Can someone > enlighten me? In my experience it makes a big difference, helps avoid big-ball-of-mud monolithic I-Am-The-Database packages written in house, makes schema changes very very simple, and requires little code. A. -- http://www.aarontrevena.co.uk LAMP System Integration, Development and Hosting _______________________________________________ BristolBathPM mailing list [email protected] http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm
