Did you know that a train goes through town at 2am? I know this because that’s about the time I went to bed. I actually went to bed before midnight but I just lay there, wide eyed and staring at the ceiling thinking about how now that I had installed DBIx::Recordset I could create a generic page to deal with this system I’m building for my clients, and not 6.
I got a lot done over the weekend by creating one page and then copying it six times, changing the code that deals with the database to be specific to that page, etc. A lot of the code was very generic and didn’t have to be modified, the only things were the edit/save and some of the specific stuff to certain data types (ie: on one page they want the boolean value to show up as “PASS” / “FAIL” and on another it’s “Y” / “N”. This worked “ok” to get things done. On Monday it was sent to the client with a “it’s not completely done but the majority of it is there for you, should be polished off in a couple of days” note.
Monday afternoon I get an email back with a bunch of changes, this field comes from here and not there, etc etc. Stuff that if I had known it when building the pages originally, would have affected how I wrote it to begin with. So I went back in and started changing and adding fields, table joins, etc (Cuv, I don’t care what you say, changing the backend layout of a DB when using pure DBI sucks! I really hate counting the number of “?”s in a prepare line :-). An couple of hours into this I realized that not only does doing this really suck, but I still had all the other pages to do.
[Go to bed. Stare at ceiling. Get up and work more.]
I started with a different set up last night. A page that is passed a “page=pagename parameter. Inside the page is a big-ass data structure (an anonymous hash of hashes pointing to an anonymous arrays of hashes) that described both “global” data (the name of the table, specific table joins that are made, page titles) and a field list that contains the array of fields, and information about each field (column name, is it a local column or from a join, type, size, text labels, content validation). I think that with DBIx::Recordset I can use the fact it simply takes a hash of fields and values for it’s record creation and saving to create a completely generic page display engine, but also a data edit/save/new engine.
I got a bit into it last night and then realized I was staring blankly at the screen for long periods of time and that it was time for bed.