How to insulate yourself from static methods

Sometimes your code needs to call a static method in a 3rd party library and unit testing suddenly becomes difficult, particularly when that static method requires context in order to work. Enter the insulating class (also known as a Facade). Create a new interface that declares a method with the same signature as the static method you want to delegate to Create a new Facade class that implements the interface Replace the calls to the static method with calls to your new Facade class Let’s assume that the method you need to call looks like this [Read More]

How to divide without using division operator

I attended a talk at the Toronto Agile Tour on Deliberate Practice that focused on TDD Games and other programming challenges like Kata. Among the challenges were things like solving a problem without using the ‘if’ keyword, or without using primitives. Solving simple problems using these challenges makes us better programmers because they force us to come up with multiple, creative solutions to the same problem. Here’s my solution for how to divide without using the division operator (“/”) in Java. [Read More]

Life after Java?

There has been a lot of talk lately that Java is on its way out, mostly fueled by Apple deprecatingJava, and by Apache threateningto quit Java. I’m not crying Chicken Little just yet, but perhaps it’s time to start looking for the Next Big Thing. There are certainly a lot of contenders out there: Ruby (and Rails), Scala, Groovy (and Grails). My guess is there’ll be a couple of false starts before a clear winner is declared. [Read More]