Friday 26 September 2008

What's your vanity rank?

A vanity search is when you type your own name into a search engine.

Now, most of us vanity searchers have learned that we are not alone -- there are pretenders out there using our names! So I propose a new term: "Vanity rank". To determine your vanity rank, simply do a vanity search and find the first link that refers to you rather than some doppelganger.

What's my vanity rank? At time of writing -- using Google -- it is 2 as Daniel Prager, and 1 as Dan Prager.

Please look out for my coming book, "How to boost your vanity rank", Narcissus Press, a subsidiary of Mirror Corp.

Tuesday 16 September 2008

Why Scheme rocks

Scheme is a modern Lisp dialect. It's what I program in for fun, and to learn new stuff.

Why is it so great? In a word, meta-programming. I can bend the language to my will.

For example, I have just added my own tracing to function definitions, without touching the insides of the function. Instead of using the built-in (define ...) I use my own 12-line* macro (define-with-trace ...). Now all I need to do is figure out how to redefine define.

Here is a more poetic endorsement.


* Plus 4 lines of auxiliary code.

Monday 15 September 2008

Let My Textbooks Go!

There are three problems with prescribed textbooks:
  1. A generally low standard: Feyman's anecdote. Has anything changed since the 60's?
  2. An inflated sticker price: A NY Times article explains how textbook publishers are like big pharma.
  3. Limited content: So learn how to search the interweb!
Textbooks are starting to be given away for free. One free one that I have bought -- because I wanted a dead leaves version -- "one of the great classics of Computer Science" - Paul Graham.

This is free as in free beer, which addresses point 2. Point 1, the generally low standard, might be helped by more collaborative work on the content, taking a leaf out of the free software movement.

We'll see ...

Monday 8 September 2008

Unit testing vs Scenario testing

Miško Hevery gives some excellent advice on designing testable software here, and elaborated here:
  • Unit Testing as the name implies asks you to test a Class (Unit) in isolation.
  • If your code mixes Object Construction with Logic you will never be able to achieve isolation.
  • In order to unit-test you need to separate object graph construction from the application logic into two different classes
  • The end goal is to have either: classes with logic OR classes with “new” operators.
Here's the explanation / summary:
Asking for your dependencies instead of constructing them withing the application logic is called “Dependency Injection” and is nothing new in the unit-testing world. But the reason why Dependency Injection is so important is that within unit-tests you want to test a small subset of your application.

The requirement is that you can construct that small subset of the application independently of the whole system. If you mix application logic with graph construction (the new operator) unit-testing becomes impossible for anything but the leaf nodes in your application.

Without Dependency Injection the only kind of testing you can do is scenario-testing, where you instantiate the whole application and than pretend to be the user in some automated way.
My emphasis.

Now, this is not to say that you don't need scenario testing, but I have found by bitter experience that trying to mock bits and pieces in scenario tends to be more trouble than it is worth: You end up with large and unwieldy pieces of testing infrastructure.

My current recommendation is that you need to test in both isolation and integration:
  1. For isolation (unit testing) use TDD and dependency injection, or DBC
  2. For integration, use scenario-based testing on the actual application using some kind of scripting interface.
Other specialist tools may be useful. For example, for highly graphic applications it is invaluable to be able to step-through the scenario tests to visually confirm what is happening on-screen. Visual diagnostics are also a great help for this "semi-manual" testing.

Amazon's recommendation system is too good

Amazon makes it too easy to reliably find -- and purchase -- good books.

The histogram of star-ratings, the user reviews, the cross-referencing with other books bought by people who bought a particular item, and what people ended up buying who looked at all make it easy to track down top books in any given area. Not to mention the access to second-hand books, especially for out-of-print items.

Coupled with the recent strength of the Aussie dollar and the exorbitant cost of purchasing locally, Amazon has proved a recent drain on my finances and a burden to my bookshelves.

So I am resolved: I am not ordering any more books from Amazon for the rest of 2008.