Code Samples

These are some code samples I put together for a job application.

MuleSource

This work is open source, so I will link directly to the fisheye subversion browser (sometimes fisheye is a bit slow; if you would prefer I can place everything in a tarball - please just ask). It is Java 1.4 (no annotations or generics) and follows company style guidelines.

I want to show "real" code, even though it includes all the compromises you'd expect from working on a 2.x release of a complex, existing product under "startup pressure" - I think one of my strengths is being able to adapt to existing code and short deadlines (the flip side of that, though, is that I sometimes feel I don't fight hard enough for time to refactor and polish).

Bean Definition Parser

This first example takes an XML configuration file and constructs an "endpoint" (we build on Spring's Extensible XML authoring). These are complex Java objects responsible for receiving and sending data. Many different endpoints exist (several for each transport - HTML, POP3, JMS etc) so the challenge here is to make something that is easy to configure (by whoever is writing a new Mule transport) in the simple cases, but sufficiently flexible to accommodate whatever extra configuration options might be necessary.

I have worked extensively on the Bean Definition Parser support in Mule. My aim has been to construct a modular library of generic components. In the code below, for example, the parser responsible for configuring instances of a core Mule class is composed of three delegate parsers, which all take information from the same XML element (different attributes are enabled for each). In addition, standard pre and post-processors allow us to "plug in" additional checks and processing.

Notification Manager

This example is more self-contained - a set of classes that allow users (via the XML config, but not shown here) to register listeners for particular events. The dispatch of events is based on the type of event at runtime, using reflection. So a listener may be registered for any class (and the relevant subclasses), and any object can be submitted to the manager as an event - the manager must then send that event to all suitable listeners.

The requirement here was to make a more efficient implementation, since notifications can be generated within fairly tight loops in the system. I achieved this by pre-calculating and caching as much information as possible. In addition, client code can ask the manager whether a particular event would be used (in a similar way to the standard logging interface with "isDebugEnabled" etc). Studying the unit test below should help clarify what is expected.

Tiny Language for Test

This is perhaps a bit "too cute", but since it's isolated in a test case there's no harm done, and it's a good example of the kind of thing I enjoy doing when I get a chance.

Numerical

The above code is Java "enterprise" work. This final example is from 10 years ago and shows a simple numerical example in C. It is an implementation of the 2D Kolmogorov Smirnov test (two samples) that is O(n log(n)) - the standard algorithm (eg Press et al) is O(n^3).