Monday, 26 January 2009

Predictably Irrational: the international financial crisis

My eternal gratitude to Dan Ariely and his Predictably/Irrational blog for pointing out the existence of a radio programme and its transcript in PDF, which for the first time properly explained to me why we're in such a mess. I wonder what collective idiocy is next up.

It also provides a sobering reminder that it's usually a bad idea to throw money at a problem. In this particular instance, Gordon Brown's fantastic idea to "save the world" by hosing all our cash and then some into the banks' pool of money supply was such a bad idea that it must stand as one of the most monumentally stupid decisions of all time. Read the transcript yourself to find out why.

Anyone without the requisite quarter of an hour to hand can refer to this very much more succinct, but necessarily less thorough, tale. It seems prescient, having been posted in 2005!

Friday, 23 January 2009

How to write conference session proposals

Most of you probably already know how to do this - after all, you get your papers accepted at conferences all over the world all the time, right?

If (like me) you find your brilliant ideas trampled underfoot as often as not, read Kent Beck's advice. It may have been written over 15 years ago, but I'm certain it applies equally well today. It's also charmingly self-referential.

Tuesday, 6 January 2009

Mock external components using AOP

Mark Nadelson has provided a well-written tutorial for a novel (to me, at any rate) use of Aspect-Oriented Programming in Java. Read the "print" version to get the whole article in one lump without the commercials.

When you write jUnit tests, you often encounter a need to create mock objects (e.g. using JMock or EasyMock) that can simulate some external dependency of the software under test. Mark has extended this idea to any external component that has an interface. In order to determine whether the software under test uses a mock component or the real one, he uses dynamic aspect-weaving by means of Spring AOP with AspectJ annotations.

I've got to have a play with this approach to see whether it can be used flexibly enough to support TDD fully. One problem I could foresee is that the pointcut specification is not in the test script but in the mock object (i.e. the class that implements the aspect). So it might be less than straightforward to link the mock object to specific test cases/steps. By contrast, when you use JMock in a jUnit test, you specify both the mock object and its expectations in one place.

Monday, 5 January 2009

XPath made simple

I know I'm a bit behind the curve on this one, but I've only just stumbled across a really useful tool:

XPather can
  • generate XPaths while browsing or inspecting HTML/XML/*ML documents
  • evaluate your XPaths and inspect the results
  • extract the content of *ML documents
The latest version 1.4.1 was released on June 18 2008 (Firefox 3.0 compatible).

XPather is a simple Firefox extension that integrates both with the browser and its DOMInspector. It is designed to be lightweight and cross-platform. It is valuable mainly as a web/XML-app development and debugging tool. In combination with the DOMInspector, which I can also highly recommend, it is particularly useful for developing WebTest scripts: right-click in any element of a page that you want your script to compare or set, and the option "Show in XPather" pops up a new window with the precise XPath to select that element.