My sample page now looks significantly different. The ‘Author’ field links to another web page (a very sparse one currently; more will be added eventually). And there are ‘Last Read’, ‘Rating’, ‘ISBN’, and ‘Own’ fields (all optional). The ISBN field links to an appropriate Amazon page.
A quite pleasant afternoon of programming, all things said. For historical reasons, there were already separate ‘Book’ and ‘Author’ classes that inherited from a common ‘Entity’ base class, so adding the author pages largely consisted of moving methods from ‘Book’ up to ‘Entity’. One of the methods in question was a ‘printField’ method; that method made it basically trivial to add more fields to the book pages.
And it’s getting very easy indeed to add new acceptance tests. If I want an acceptance test that checks that a new field is working properly, now all I have to do is add a new entry to the database where that field is present and stick a file ‘fields-NN.html’ (for an appropriate number NN) with the expected output. No need to modify the acceptance test proper at all, and that acceptance test is all of three lines long:
Hidden behind the scenes is functionality to compile the program, generate a target web directory, run the program with the output going in the target directory, do some wget calls to the web server I’m running on my laptop, and compare the results to the expected html output.
Which is pretty slick. I’m embarrassed to say that, at work, I don’t get my hands dirty with acceptance tests as much as I should, so I’m glad I’ve been getting the experience here. And I’m starting to understand how a tool like FitNesse could work, allowing a customer (an actual customer, not a program) to write new acceptance tests just by modifying some simple configuration files.
I’m also proud the test that checks that my Amazon links are correct by digging the link out of my web page, fetching the linked-to page from Amazon, and checking to make sure that it actually links to the book that it’s supposed to. So if Amazon ever changes the format of their links, my tests will let me know!
At this point, dbcdb is quite useful; the database now contains every book I’ve finished reading since I started the project, and the resulting pages have almost all the info I’d like them to have. The next thing I’d like to do is plug in an appropriate style sheet, because they look like crap; that will require essentially no programming, but I’ll have to learn more about cascading style sheets. (And acquire some design sensibilities, which is a good deal harder.)
I spent a little bit of time learning about Ant; I’m not sure I like it very much, though. In particular, one aspect of Java that I’m using is that different classes can each have their own ‘main’. This means that, if you’re interested in one particular program, you probably only want to compile a subset of the classes in your source directory. I don’t know if ant supports that, but the tutorials I’ve found online certainly don’t explain it if it does. Whereas make handles that sort of stuff with its eyes closed. But I can’t get make to handle dependencies correctly (I found another dependency bug, so now I do ‘ make clean’ in my first acceptance test, which means it takes more time than all other tests put together), so I guess I’ll have to move to ant eventually.
There are no revisions for this post.