Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Do I need a database model?

by sundialsvc4 (Abbot)
on Mar 11, 2014 at 13:03 UTC ( #1077839=note: print w/replies, xml ) Need Help??

in reply to Do I need a database model?

In my opinion ... and it is “my opinion” only ... ORMs turn out to be a colossal (a) waste of time, and (b) source of complexity and maintenance headaches.   And yes, I have dealt with many very-substantial applications that did it both ways.

Instead of elaborating on these matters, though, my core objection to them is really one of philosophy.   The foundational argument behind these classes is the premise that “a database table === an application object.”   This is very rarely the case, IMHO.   Instead, a set of database tables provides the data source(s) for “a proper ‘application object,’” and the object itself consists of much more than simply a programmatic expression of a 1->1 and/or a 1->M relationship.   In a real-world sized application, many related objects might draw information from the same table, yet the structural strength and integrity of each of these objects is, yet again “IMHO,” considerably weakened(!) by spinning-off parts of it to a “third-party class” which represents any single table and which seeks to express anything anywhere that has anything to do with this particular table.   Note that you can commit this error with or without DBIx, but DBIx and its kin make such errors (IMHO) considerably easier to commit.   A program-object is not necessarily a data-object, and a pure-data-access object often is not useful and (IMHO!) does not belong.

My career experience consists mostly of dealing with now-recalcitrant applications, many of them built over the last five to ten years, which at the time were very lavishly built but which now are collapsing under their own baroque weight.   (As such, I do not fear running out of a job anytime soon ...)   These monsters are being scrapped, decommissioned, or “in-sourced,” left and right now, and one of the key reasons for this is their “bespoke” complexity.   The system must be changed in some deep way, so the logic pertaining to what it does now must be cleanly isolated, extricated, and replaced ... but there is simply so much coupling within the system, so many source-code modules (and configuration files) that must be simultaneously understood and touched, that the software-machine becomes unmaintainable.   Since data (structure and access) touches literally everything everywhere, it becomes the straw.

Replies are listed 'Best First'.
Re^2: Do I need a database model?
by Your Mother (Chancellor) on Mar 11, 2014 at 15:09 UTC

    DBIC is shorthand for DBIx::Class not DBIx. DBIx is, in fact, nothing but a prefix. There is no DBIx module. There are several hundred DBI based packages that use the DBIx prefix and many differ completely in purpose and usage.

    DBIC does not simply abstract 1:1 with tables. ResultSets and Result classes cover a lot including plain highly reusable SQL like SQL::Abstract, without necessarily mapping to an existing table at all. And in DBIC there are column objects, storage object, schema objects, and more. Chained ResultSets is one of the most powerful and liberating ideas in DB code.

    DBIC is more complicated than a plain SQL library but if written with the same kind of discipline it takes to keep an SQL library from turning into spaghetti it is self-documenting, highly extensible, repurposable, self-deploying, versionable, etc, etc, etc. Many, every one Iíve seen, home grown SQL libraries take on some of the characteristics of a good ORM, except they tend to do it atrociously without testing or sanity. NIH is a the prime cause recalcitrance in some applications.

    Please provide literal examples instead of philosophy if you're going to make this kind of argument. Several of us have provided good, clean examples of DBIC on the site before. If you have a better approach, everyone would love to see a CUFP post on it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1077839]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2017-02-20 05:37 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (294 votes). Check out past polls.