Sunday, September 16, 2007

DB Relief

Database again
 This session starts off much more smoothly. I've got a stored procedure to check for duplicate item names now, and testFindOrCreateBookOfKnowledge is working fine. Next is to tie this into the class itself.

Data Entry
 I add my three existing items first (so that I'll have the IDs). I discover that Ukelele is actually spelled Ukulele. Oops. Ok, I've replaced the hardcoded switch with a database call, and a few tests are failing, but I think they just need new snapshots (as I made up arbitrary IDs before). Excellent, new snapshots make everyone happy.
 Now I need to replace the individual setup functions for each item with a "load by id" call. It takes 22 lines (including references to the CanonicalItems object) to create the book of knowledge, for example. I should be able to reduce that to just a few lines.
 Almost - I still don't have the item abilities in the database, so I need some custom code still. Again, debug print doesn't match (ID changed), but it's easily remedied.
 Ukelele. Updated functions. Reviewed failures. Updated snapshots. All tests pass.
 Stage Pass. Updated functions. Reviewed failures. Updated snapshots. All tests pass.
 Refactoring - replace specific setup functions for each item with one generic function. Even though I have to make additional calls in some places to add abilities, I can do that in the main setupTests function. This will help make the setup dependancies more clear.
 Actually, considering how easy it is to create an object now (and, moreover, with the certainty that the object will always be the same), I might be able to remove the object from the global parameters array eventually (and just create it on demand). This would also take care of the dependancy problem, as I'd be creating objects as I need them.

Short session
 That's it for now, time to take a shower and get ready for church. Although this session was shorter than last night's 2 hour marathon, it was a lot less frustrating and (I feel) more productive.