Quirksmode
Another one for the bookmarks: Peter-Paul Koch’s Quirksmode.
29 Oct 2003 Sam comments off
Another one for the bookmarks: Peter-Paul Koch’s Quirksmode.
29 Oct 2003 Sam comments off
Somehow I managed not to be at the Apple Store tonight for the Panther release. I would have had to settle for the store at Southdale anyway, since the one at the Mall of America is closed for remodelling (!). The Southdale Apple store is fine — I stood in line for its grand opening, no regrets — but a bit dinky. Besides, I don’t feel that I can drop $130 right now. So I shall wait for Panther, at least until next payday, and live vicariously.
24 Oct 2003 Sam comments off
I’ve been doing test-driven development for several months now and am not looking back. I don’t remember what first inspired me to read Kent Beck’s book on the subject, but I sure am glad I did.
I was already sold on the idea of unit tests. (These are tests for individual units of code — be they methods, classes, or what have you. If you’ve ever installed a CPAN module or run make test
, you’ve seen unit tests at work.) However, they had not yet wormed their way into my actual coding practices. You know how it is: sure they’re a good idea, but when would I have time? This was part of the initial appeal of TDD. By writing the tests before the code being tested, I’m guaranteed to have tests.
This is far from the only benefit, though, or even the most important one. Testing my code before I write it makes me carefully and continually work through the design, facilitating exploration of interesting ideas and discard clearly ridiculous ones before I get too far into them. I’ve found that TDD helps me develop cleaner, more robust code. Writing implementations for an interface before I’ve even written the interface helps expose flaws and vulnerabilities that I likely would not have discovered until much later.
It’s difficult to understand until you’ve tried it for a while. But I really do write better code this way.
Sound confident? Yep. Beck writes a lot about how the test-driven cycle improves programmer confidence because of the immediate feedback and stream of small successes. Pragmatic Programmers Dave Hunt and Andrew Thomas also suggest test-first model as a way of breaking through the fear of the blank page (er, empty buffer). Start by writing a simple test, so simple that you wouldn’t normally bother.
The advantage to starting with such a trivial test is that it helps fill in the blank canvas without facing the distraction of trying to write production code. By just writing this very simple test, you have to get a certain level of infrastructure in place and answer the dozen or so typical startup questions: What do I call it? Where do I put it in the development tree? You have to add it to version control, and possibly to the build and/or release procedures. Suddenly, a very simple test doesn’t look so simple any more. So ignore the exquisite logic of the routine you are about to write, and get the one-line test to compile and work first. Once that test passes, you can now proceed to fill in the canvas — it’s not blank anymore. You’re not writing anything from scratch, you’re just adding a few routines…. (“The Art in Computer Programming” (PDF).)
Kimbro Staken recently wrote about encountering programmer’s block. TDD is one way I handle this situation. It just helps me start doing stuff. If I could convince someone to pair program with me, I think that would help, too.
A coworker agrees TDD is interesting and he’s certainly all for unit tests, but considers TDD a waste of time when just experimenting. On the contrary, I think that experimentation is exactly when TDD is needed. Sure, if I’m writing a one-off script, there’s no need to write a test. But if I’m putting some effort into experimenting, maybe half a day or more, TDD is worthwhile because of how it supports exploration of ideas. Rather than first writing a class, then discovering the mistakes I made in designing its interface, I implement the interface right away and figure out what makes sense and what doesn’t. Once I fall into a rhythm (test, code, test, refactor), experimentation goes faster.
An essential part of TDD is refactoring to simplify and make designs cleaner. So TDD is also a useful introduction to refactoring (next up for me: read Fowler’s Refactoring). Because of this, TDD also served as my entrĂ©e into agile software development, in particular Extreme Programming. I’ll probably write more about this before long. Here’s a quick list of current influences:
24 Oct 2003 Sam comments off
I have such high hopes for XForms. I’m working on a project right now for which they would have proven extremely useful, but after investigating existing XForms engines and what it would take to get rolling, I decided that the project deadlines precluded my using them. Pity, because they’re very cool and very useful. I feel this way even after slogging my way through the hype.
And now they’re a W3C recommendation. Along with this announcement, we are given the handy XForms for HTML Authors. Now I’ve just got to start getting those deadlines sorted out…
22 Oct 2003 Sam comments off
If you’re looking to try unit testing in PHP, I cannot recommend Marcus Baker’s Simple Test highly enough. There are several good unit testing frameworks for PHP, (most of them, including PEAR’s, cryptically named PHPUnit) but once I tried Simple Test I stuck with it, for one basic reason: documentation.
Unusually well developed documentation was what first drew me to SimpleUnit. Not only is the API outlined in detail, but there’s an introductory tutorial to unit testing and test-driven development, with plenty of examples of how to use Simple Test. I was up and running in no time and was immediately hooked. Take this as a lesson: clear documentation attracts users/developers.
Mock object support is a nice bonus, too. Mock objects support unit testing by simulating real objects that are too difficult to set up and take down. By coding to an interface, and substituting a mock object that uses that same interface, you can more effectively test an individual unit. For a quick, accessible overview, Simple Test’s documentation works well, and I also suggest a sample chapter (PDF) from Andrew Hunt and David Thomas’s just-published Pragmatic Unit Testing. Simple Test is no longer the only PHP testing framework to offer mock object support, although I believe it was the first and was another reason I stuck with it.
17 Oct 2003 Sam comments off
In Analysis of Security Vulnerabilities in the Movie Production and Distribution Process, it’s demonstrated that most movies available for download on the Internet are not pirated DVDs, but leaked by industry insiders.
17 Oct 2003 Sam comments off
I was just talking with someone about how very cool it would be to have a screening of the entire Lord of the Rings trilogy, and whaddya know, they’re doing it.
Now, are they doing the same thing for The Matrix? Seeing Revolutions at an IMAX theatre will be cool. Seeing all three at once at the IMAX would be mind-blowing.
10 Oct 2003 Sam comments off
I’ve reconciled myself to using tables to lay out forms, consoled by the idea that forms can be considered “interactive tabular data.” — fully aware that’s just an excuse, something I tell myself so I feel better (not so guilty). Richard Rutter suggests using definition lists. An interesting and satisfying idea, one I began to give serious consideration, trying to decide which technique I prefer. Then I realized something.
It doesn’t matter.
Sometimes, definition lists make semantic and practical sense in forms. I’m grateful for the idea. Sometimes, tables are more appropriate because the form is indeed tabular data. Sometimes mixing the two may be better. When it comes to doing the work, I’ll choose whatever is most appropriate to the content.
And in a year or two, I’ll look back at this and marvel at how naive I was.
09 Oct 2003 Sam comments off
I’ve started work on a project in which I need to generate bar graphs, so naturally I turned to GD::Graph, a Perl module for doing just that. I expected that when I created my first image, I’d be excited to have accomplished something moderately difficult (or at least typing-intensive) like creating an image out of nowhere. But it was too easy. It only took a few minutes before I had my first PNG. How terribly unsatisfying. :-)
09 Oct 2003 Sam comments off
Congratulations to our friends Jim & Camille Holthaus on the birth of their son Jacob. And to their first son, Robert, who now has a little brother to play with.
06 Oct 2003 Sam comments off