Using Mockito to Unit Test Java Applications
Feb 25th
If you’ve spent any time writing unit tests then you’ll know that it’s not always straight-forward. Certain things are inherently hard to test. In this post I’ll show you the basic principles of creating mock objects with a little help from the Mockito mocking tool.
One common problem faced when unit testing is how to test [...]
Configuring MySQL on Mac OS X
Feb 23rd
I found the documentation for MySQL a little rough around the edges recently when I needed to change a configuration setting for it – everything seemed spread around their comprehensive PDF documentation and it took me a little while to fathom my way through it.
It’s not often that changes to MySQL configuration need to [...]
Using Assertions in Java
Feb 18th
I’ve been working on a project this week and have been delighted to see that the original team of programmers who developed it have made the effort to use assertions in their code.
The assert keyword was introduced in Java 1.4 and has since been a sadly under-used language feature. Assertions offer developers a neat [...]
Counting the Days Between Two Java Dates using a Gregorian Calendar
Dec 2nd
Today I needed to figure out a way to count the number of days between two dates in Java. There are no API methods that will do this for you so a little work is required to achieve this. This post illustrates the solution I came up with.
Ignoring Files and Directories in a Subversion Project
Dec 1st
Configuring Subversion to ignore files can sometimes cause confusion. Like most things though, if you understand the basic principles, then its not tricky at all. In this post I’ll demonstrate just how you should go about ignoring files in a subversion project.
A Unix Command to Recursively Delete all .svn Folders
Nov 25th
I recently needed to check out a project from Subversion and then delete all of the .svn files from the project directories. Google found me a few different ways to do this, but none of them seemed to deal with a case where some of the directory and file names had spaces or quotes in them – as mine did. After a little experimenting, I figured out how some simple Unix commands that could be combined using pipes to do this.
The Details of Member Level Inner Class Syntax
Nov 17th
Inner classes offer are a powerful extension to Java’s object model. However, the syntax for some of the more advanced features of member inner classes is quite tricky to get to grips with. In this article I’ll explain the full details of this syntax.
An Explanation of ‘this’ in Java
Nov 8th
As every Java programmer should know, code within any non-static method can access the current object via a special reference called ‘this’. Just how this works may not be immediately obvious so I’ve taken a moment to explain it here.
Programming with Inner Classes in Java
Nov 8th
Inner classes are an advanced programming feature in Java. They add another dimension to the concept of Object Oriented programming by allowing objects to not only reside alongside one another, but also within one another too. In this post I’ll explain how inner classes work with the help of an example that illustrates their most common use: Swing GUI programming.
Branching and Merging with Subversion (SVN)
Nov 1st
Working in the head revision of a versioning system isn’t a great idea. It’s much better to work in a branch and to merge the changes once you’re convinced they are stable. This post demonstrates how to do this with Subversion.
