Ovid (publius_ovidius) wrote,

Swiss Army Chainsaws

Perl has been described repeatedly as "a Swiss Army Chainsaw" because of how incredibly flexible it is (hell, I built a predicate logic engine using regexes. It really is flexible). Unfortunately, some people want to extend that "general purpose nature" to special purpose code. As a result, we get "frameworks". Frameworks are nice, but only when they're nice. When they're not nice, developers have a nasty habit of figuring out more and more ways of making them nice. And nicer. And adding more blades and engines onto every nook and cranny of that chainsaw until eventually you just know it could do everything you need, if only you could wade through the manual -- assuming there is one.

I hate that. I really, really hate that. Here's what I want:

Solve the 80% of the problems with the 20% of the code and then figure out how to expose just enough to the programmer to let him or her solve the rest they way they need to. If they need to.

Case in point: in trying to resolve a particular issue at work, I needed to understand the inheritance hierarchy of some code which uses DBIx::Class, an object-relational mapper written in Perl. It's a fantastic tool. It's a great tool. It's a Swiss Army Chainsaw of ORMs.

Uh oh.

We have a "clip" table. With the exception of two fields which should be managed by the database (but aren't -- they're handled by the 'AuditedObject' class you'll see below), we really only need to save 6 pieces of data in this table. Got that? One table with six columns. Here's the class hierarchy:

(Click on the image (and then click again) to see the inheritance heirarchy in all of its glory)

Bad, bad, bad inheritance hierarchy
Bad, bad, bad inheritance hierarchy
Absolute Nightmare of An Inheritance Hierarchy

Yeah, there are some problems in our code, but once you get into the DBIx layer, it's a twisty-little maze of passages. Good luck debugging that.
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded