September 22, 2007

Turning a corner on unit testing

Posted in Coding, Development, Me at 3:53 pm by mj

I think I’ve finally done it.

This week, I found myself struggling within the confines of existing infrastructure code that had no unit tests. The task was relatively simple: a new feature at the infrastructure-level that would enable many other product-level features in coming months. If I’d gone down the hackish route and not worked at the infrastructure level, I could’ve isolated this code and tested it in complete isolation. But that would just lead to more bugs down the road, and I’d still have a lot of integration testing to do.

It was one of the more painful and slow development experiences in recent memory. Even worse than dealing with 10-year old, undocumented, legacy Perl code written by non-programmers. Yeah, that painful.

For a long time, I contended that unit testing’s primary benefit was long-term: ensuring that refactoring code which you did not write and do not fully understand does not break. And that you need to reach a certain critical mass in terms of number and variety of tasks before it becomes effective. And that’s still true. I think my skepticism rubbed off, too, because I hardly hear anyone saying, “But the unit tests pass, there can’t be a bug” anymore.

But then I started looking at how I approached the practice of programming. Before I write code–often as part of designing the system–I write out stubs of how I’m going to use the code. Because an aesthetically unpleasing or overly complicated API is an error-prone API. And it dawned on me that this is one of the big benefits of test-first development.

Last year, when I read Agile Software Development: Principles, Patterns, and Practices (finally after it had been on my bookshelf for years), it was a bit like a revelation. Agile development, really, is formalizing what are otherwise good development-time practices anyway. So I resolved to better formalize my development activities.

It’s taken a while, but now I am so accustomed to using unit tests to isolate problems, and the quick turnaround that entails, that there is a significant mental barrier to any other way of doing it. I’ve turned that corner and am heading down NotReallyUtopiaButGoodEnough Street.

September 18, 2007

Bad summer for motherboards

Posted in Life, Me at 12:56 pm by mj

Back in June, I blogged about the motherboard on my Dell PowerEdge going out.

Last Wednesday, my GE refrigerator/freezer went out. The fan was still blowing, but the air wasn’t near cold enough.

Most of the food in the freezer unthawed before we even realized there was a problem, and the refrigerator was above 45 degrees.

We tried our best to eat all our still-fresh-smelling recently-thawed meat, and bought a bit of dry ice and regular ice to help with the refrigerated stuff, but I wasn’t going to take a chance with most of the food. Replacing $300 of food is less painful than throwing up for 3 days. (No, I don’t need to scientifically verify the fact, thankyouverymuch.)

Today, the friendly GE repairman came and isolated the problem to… the main control board (motherboard). The battery had burned a cute little hole straight through the board.

Unlike the Dell, he replaced it within 15 minutes and was gone. No need to reinstall an OS, even.

Of course, the fridge is several times more expensive and the extended warranty was $80…

September 16, 2007

An Observation on Web Writing

Posted in Books, Reading, Writing at 9:08 pm by mj

I’m currently reading three books that, unexpectedly, illustrate the difference between writing for the web and writing for physical books, and helps explain why I often feel so unfulfilled after catching up on my feeds. Two of these books are essentially blog posts edited for print, while one is a popular science book.

The first is Managing Humans by Michael Lopp. I’ve been reading for a while. I find his style (on the web) informative and hilarious. In print, however, I feel like I’m reading a For Dummies book. Maybe it’s the yellow cover. But the big, bold Easy Reader-esque headlines every third paragraph certainly aren’t helping. Is it still funny? Yes. Is it still informatiive? Yes. But it’s obviously self reflective, and doesn’t contain much beyond Lopp’s personal experiences.

The second is Smart and Gets Things Done by Joel Spolsky. Just like 98% of every other programmer, I’ve been reading for what seems like forever. He also has a great blog “voice,” and his posts feel natural while also instructional. The print edition of his columns, on the other hand, is tiny (the only books in my collection that are smaller are some O’Reilly pocket reference editions) and the print is larger than normal. Reading this, I don’t feel like I’m getting much out of it. Maybe that’s because I’ve gotten so much out of his faux blog over the years.

Now let’s compare these–as I’ve serreptitiously done–with a popular science book. A book without any numbers or graphs, and a large number of “Just So” stories and fictional recountings of everyday life.

I’m talking about Sperm Wars by Robin Baker. Baker doesn’t spend time with scientific details, and, as I said, many of his explanations are plausible “Just So” stories (I mean that in the positive sense). Whatever scientific evidence lies behind them, he leaves as an exercise for the reader to discover elsewhere. It’s highly entertaining, if a bit embarrassing to read on BART (after a few, um, “close calls” with reading nearly-pornographic sections with an attractive woman sitting next to me, I decided to finish it at home lest anybody get the wrong idea).

And yet, for all the scientific evidence it leaves out, it’s a normal-sized book with normal-sized print and normal-sized chapters. It’s a book. Both the fictional “scenes” and the explanations are entertaining and flow well. This is a book that’s meant to be read and grokked, not skimmed and (maybe) shared.

Both Michael Lopp and Joel Spolsky do well when they abide by the Web Writing Commandments handed down by the Great Spider In the Sky lo those many years ago. I doubt if I would read either if they didn’t–and neither would many others. I don’t abide by those commandments, but that’s the least of my problems with this blog.

But here’s the thing: does making it easy to scan your posts and, therefore, discover and subscribe to your blog mean that your readers are connecting with you the way they would a traditional print author? I read a lot of great blogs. I learn a lot every time I have time to catch up on my feeds (about once a week). I’ve spent time organizing my Google Reader folders/tags so I can easily skim the media type blog headlines, I’ve segregated out partial feeds to the point I almost never bother “reading” them, and more… all with the goal of saving more time to get more out of the other, more valuable blogs I read.

And still, there’s nothing like a good–or even decent–book. I just don’t feel the same satisfaction.

Am I alone?