Menu

Pattern matching in Java with the Visitor pattern

February 11, 2015

I once read an essay—I cannot find it now—that talked about how learning a more advanced programming language can improve your coding even in a language that lacks those features because those language features are really ways of thinking, and there’s no reason you cannot think in terms of more powerful abstractions just because you… Read more

Mocking Java enums with jMock is both trivial and impossible

October 02, 2013

I recently ran into a situation where I needed to test some code that used an enum to select between various strategies. As a toy example of this, we’ll use Accounts which have a list of investments and a Strategy which defines what investments are acceptable. View the code on Gist. Strategy is a Java… Read more

I can haz lambda on Java 7?

April 29, 2013

Superficially, lambda expressions in Java 8 are just syntactic sugar for instances anonymous inner classes. Syntactic sugar should not require classfile changes, so one might expect that code compiled with Java 8 lambdas could run on a Java 7 JRE. It turns out that you can’t do this, and not just because of an automatic… Read more

Not too late to sign up for Odersky’s Scala Coursera class

April 02, 2013

Just a quick note if you haven’t seen it. Martin Odersky is teaching a Coursera class Functional Programming Principles in Scala. On the backend we’ve been experimenting with how we can use Scala more easily in our 99% Java project, and apparently we’ve been talking about it enough that Matt Baker decided this was a… Read more

Hurricane Sandy puts YAGNI to the test

November 13, 2012

On Sunday night, Oct 29th, we learned that most US equities markets would be closed the next day due to Hurricane Sandy. This is very unusual: the only times the market has been closed since the four days following 9/11 have been the National Days of Mourning following the deaths of Presidents Reagan and Ford,… Read more

Get thee to a nullery: self-aware nulls for testing

April 11, 2012

Pryce and Freeman’s Growing object-oriented software is a good practical guide to test driven development, as you’d expect from the authors of jMock. It isn’t necessarily easy to adapt piecemeal — introducing end-to-end tests after the fact would require a lot of rewriting and probably introduce more problems than it would be worth assuming you… Read more