I'm Tom Jaeschke and you may contact me at tomjaeschke@tomjaeschke.com or (512) 419-8788.

Thursday, April 15, 2010

Yay Tests!

I've built an elementary CMS for a client of a client. There is a backend administrative system for adding pages and specifying their URLs that looks like this:





In the example above the fourth row is selected for editing. Here is a closer look at how the URL is specified:





http://www.example.com/infor/industry/high-tech-and-electronics/ is thus the path to the page. Here are some notes on how the routing was handled: of both CMS routing and forcing browsers to close



A look at the database table that drives how the pages are organized reveals the magic is kept in a column called suggestedPriority. More on the schema here: When to Alphabetize





So obviously records are sorted by suggestedPriority. The arrows in the second image above allow for moving pages up or down relative to a first, second, or third "folder." This allows for organization of the menu system. If one uses a second folder arrow, all of the adjacent pages with identically-named "second folders" should get moved up or down relative to nearest cluster of pages with identical second folder names. This ended up working too well and clustered pages together by matching on only second folder names while not checking for a discrepancy between second folder names and first folder names.



There was bug that was not addressed by unit tests.



Luckily, I had enough other unit tests to quickly lay hands on the problem and address it, writing new unit tests. The speed of finding the bug came largely from knowing what I did have under test already. If I had written the page sorting means without TDD I would have written a mess that I had no confidence in, that I would be afraid to change, and that would be much more time-consuming to troubleshoot.



(This project, which I've been blogging about for weeks, "went live" today.)

No comments: