Sunday, November 2, 2008

Speaking of refactoring

The stuff in the last post is all AFTER fixing the hash/hashref argument problem.

Also, Handler/Commenter.pm is no more. Its code and a genericized status() have been folded into Util.pm.

DOM problems in bringing Grammarian online

As I'm 99% sure I've mentioned before, the DOM was the 2nd component of the Grammarian stack to be written. It got a syntax-wise overhaul approximately a year ago(!), but its capabilities were laid down in spring/summer of 2005.

Turns out I wrote in all kinds of crap that Carrot will never use. Perhaps I was thinking "this will be an awesome, general-purpose structured document framework which everyone will want to use", but that was a stupid thing to think. More likely I think I was simply doing everything I could figure out how to do, to make myself feel better about the enormity of the task. And I've ended up with all sorts of crufty special cases and exceptions which are now interfering with the proper operation of the system as it has ended up being in reality.

Interestingly, the test suite has been an accomplice of the problem in this issue, because a lot of the tests were written just to exercise those edge cases rather than to simulate actual system usage. I can forgive myself for this (this time) because I didn't know exactly what the system would end up doing, but there's still a really good lesson in here.

Also, the DOM TODO has exploded to fill a 4x6" index card. Looks like a severe refactoring is in order.