royvanrijn: Hmm, if people want to , they'd have to buy a koran... good for the economy and Syriac translators I guess :-)

Testing with Spring

December 8th, 2009

To improve the quality of your code it is important to thoroughly test your code. Not only using unit tests but also using integration tests. I’ll describe these terms and show examples on how to create tests using JUnit and Spring’s Test library.

Unit Testing

A unit-test is an automated test that tests one single unit-of-work. So, what is this unit-of-work? Its the smallest piece of code that can be distinguished. If you are programming in Java the smallest unit you can test is a single method. So all unit-tests should only test this single unit, and no other dependencies.

Here is an example of a unit-test:

Continue reading »

Java Generics for Compare

December 4th, 2009

I’ve been developing with Java 5+ for quite a while now. Not all developers are this lucky, some are still stuck with 1.4… some even with 1.3! But my clients all made the excellent step forward to Java 5 (some even to 6). The problem is, they moved the runtime/JDK but forget to move their developers!

In Java 5 the language brings some good improvements, the for-loop is easy to understand, and almost all the developers are using this by now. The problem starts with generics. There is a part most developers understand, the Collections API. Almost all programmers use lists now as: List<Integer> instead of a plain old List. This is a good start, but it must not end here! First, I must admit, generics in Java can sometimes be hard and confusing (when using <? extends X> and <? super X>). So I’m not going to talk about any of this ‘hard stuff’. Its the use of ‘easy’ generics that can our lifes so much easier.

For example the piece of code below:

Continue reading »

Styling and plugins

December 1st, 2009

Ok, I’ve installed a theme and I’m now adding all kinds of stuff. For example, notice above that you can see my latest tweet! A little personal touch.

I’ve also installed a code-formatter plugin, so I can do a code “Hello World” too now:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello world, from inside the code-formatter!");
    }
}
Page 3 of 3123