Over in Maatkit-land, Daniel Nichter and I practice test-first programming, AKA test-driven development. That is, we write tests for each new feature or to catch regressions on each bug we fix. And — this is crucial — we write the tests before we write the code.* The tests should initially fail, which is a validation that the new code actually works and the tests actually verify this. If we don’t first write a failing testcase, then our code lacks a very important guarantee: “if you break this code, then the test case will tell you so.” (A test that doesn’t fail when the code fails isn’t worth writing.)
Most of the time when I do this, I write a test, it fails because I haven’t written any code yet, and I then go do some kind of clean-room coding. Then I run the test and it’s busted, and I have to go back to the code and figure out why, and after a few more tries I get it working. And then it feels great. (That’s the other thing about test-first coding. It’s really satisfying, like cooking the perfect dinner, arranging the plates beautifully and then eating.)
This time I wanted to write a pure-Perl implementation of CRC32, and embed it in mk-table-checksum. We try really hard never to rely on external modules, even modules that ought to be distributed with Perl itself. That keeps Maatkit as portable as possible and makes sure there is no installation hell. You can generally just get and run the Maatkit tools with no installation. So I referred to an existing CRC32 implementation, in Digest::Crc32. I wrote a test by referring to the value I got from MySQL’s built-in CRC32:
mysql> select crc32('hello world');
+----------------------+
| crc32('hello world') |
+----------------------+
| 222957957 |
+----------------------+
1 row in set (0.00 sec)
Here’s the test:
is($c->crc32('hello world'), 222957957, 'CRC32 of hello world');
CRC32 is CRC32, so my code better agree with a working implementation. And then I wrote the code, which is a refactoring of the math in the module I linked to above. And then I ran the test, and it Just Passed with no further ado. w00t! This is pretty much a historic first for me! I thought at first that I’d screwed something up with the test, but I checked again. This is like getting a hole-in-one for me :-) So I just thought I’d share it with you. It feels awesome.
If you’re not doing test-first coding, you ought to give it a try. If you are conscientious about writing tests first, your code will always be easy to test. If you don’t, you write untestable code. Then it’s tough or impossible to ever get tests on it, and you spend the rest of your life wasting time on stupid bugs and slow, fearful development, never knowing what else you are breaking with your “fixes.”
Test-driven development is one reason The Rimm-Kaufman Group’s in-house bidding system blows away their competition. (RKG is my previous employer.) The comprehensive unit-test suite lets you know right away if you’ve broken something. That keeps the code clean and makes it possible to be extremely productive. I remember once when one of my co-workers there implemented a major feature in a very short time. It was also incredibly helpful when sharding the databases (anyone ever done this without a test suite? Would you like to share about how much of your systems broke during sharding? It was almost a non-event at RKG). The people I worked with before I joined RKG looked at me like an alien when I tried to explain that this was possible.
If you’re thinking that your code is not “that kind of code,” that “only certain kinds of code lend themselves to unit tests,” then stop. I’ve heard this before, and you’re wrong. It’s only “untestable” because you didn’t write tests first. Write tests first, and your code — all of it! — will be “that kind of code” that is testable. It’s hard. No one says it’s not; good programming is much harder than sloppy programming. But it’s well worth it.
Converting untested, untestable code into tested code is not so much fun, though. And in my experience you’ll rarely be rewarded for it, and your coworkers will not appreciate you raising the bar for them. Maybe you need a new job. I hear RKG is hiring. Did I mention that their codebase is built from the ground up on unit tests?
* OK, we’re not perfectly disciplined about this, but we’re pretty good about it.
CRC32, Daniel Nichter, mysql, Test Driven Development, The Rimm Kaufman GroupOnline music discovery and sharing sites are a dime a dozen, but they still continue to launch. For those watching this phenomenon and wondering why new startups keep entering a crowded — and relatively unprofitable — market, look no further than Kasian Franks, CEO of Seeqpod, and Dan Kaufman, CEO of Jango.
Each CEO sees music as the killer application that will lead their users into more lucrative enterprises. With Jango, which is a cross between an Internet radio station and social network, the business proposition is to license the ability to stream the music as an online radio station (as opposed to striking deals with individual recording companies), build a social network around that streaming music, and then sell targeted ads.
Jango, which launched its beta in December and has raised about $2 million from angels, allows users to type in the name of an artist and immediately hear their songs. A list of additional recommended artists is also provided. The user clicks on each band or singer to create one or several personalized radio stations, and those radio stations are shared among Jango’s users.
Kaufman, who points to services such as Imeem, Last.fm and iLike as places where people can go to find music online, says Jango is more social, and notes that the social component leads to more page views and a targeted space for advertisers. Advertisers on the big social networks don’t know where their ads may appear, he claims, so it’s worth it for certain advertisers — especially those promoting artists — to sign up with Jango. In addition to ad revenue, Jango plans to make money on transaction fees for selling music on the site, and like Internet radio stations Pandora and Slacker, will charge subscription fees for those who want to avoid ads or get access to more features.
Jango’s model is fairly conventional, in that it relies on music to build an ad-supported social network that uses ads to monetize its users. Seeqpod is different — it’s using music as a way to sell its search technology and recommendation engine. The startup, which has raised close to $4.5 million from angels, has exclusively licensed search technology from the Lawrence Berkley National Laboratory.
Taking a cue from Chinese search giant, Baidu, which has a popular MP3 search function, Franks decided that music was indeed something universal enough to get users to try out the search engine. Visitors to the Seeqpod site see a search box similar to the one at the top of the Google homepage, but also get a list of currently searched-for music that scrolls underneath that box. After the user types in the song for which he is looking, Seeqpod searches for it on the Internet and begins playing it (but not hosting it, so as to avoid legal issues).
Songs related to the search inquiry are also shown as part of Seeqpod’s recommendation capabilities. Franks says Seeqpod plans to add video search and discovery in the future, and to advertise against its results, much like Google does. In a program similar to Google’s AdWords, Seeqpod plans to work with individual artists to show ads on their sites based on music searches and split the revenue from showing the ads. Franks maintains that music is the best way to get user adoption and for Seeqpod to garner the ad revenue associated with a successful search engine. A similar music recommendation site with an eye on larger markets is MyStrands.
“Music is a suberb strategic platform for rolling out services and promotion,” Franks says. “There’s no Powerset or Kosmix here. Consumers don’t care about the search engine; [search engines] are a transition point that enables them to get to another place on the web.”
Both startups are using music as a differentiator to get market share in a crowded space that is dominated by giants: In Jango’s case, music will have to push it past Facebook and MySpace, while Seeqpod has set itself against Google. Consumers may love their tunes, but hitting the right notes with enough of them will be a challenge.

Interesting
Daniel
goog
Technology-News
kaufman
jango
seeqpod
awstats: del.icio.us tag/awstats
webmaster
webmasters
Daniel
awstats
definitions
define
malone