Apr 11 2010
a green leaf

Goals of Test Driven Development

Why should you adopt Test Driven Development?  The answer is actually more complex than many people think.

Of course we all want to have fully tested code to ensure that the code operates as expected.  We also want to ensure that any new features do not break existing functionality (regressions), but what other reasons are there?

Continue reading


Apr 10 2010
a green leaf

Getting The Context Path (Without a HttpRequest)

Web programmers know that they shouldn’t go writing JSPs with the Context Path hard coded in them.

If you do the following:

   <a href="/MyApp/path/to/controller/home.htm> Home </a>

You’ll notice that as soon as you decide to deploy your web application using a different name than “MyApp” then none of your links will work anymore.
To avoid this you need to get the context path from the HttpRequest object as follows:

   <a href="<%=request.getContextPath() %>/path/to/controller/home.htm>
     Home
   </a>

or by using a JSTL tag:

    <a href="<c:url value="/path/to/controller/home.htm"/>"> Home </a>

What happens when you are rendering HTML in your Java code and you don’t have access to a HttpRequest object for whatever reason?

Continue reading


Apr 10 2010
a green leaf

POWDER Roguelike Game

POWDER

POWDER proves that graphics really isn’t everything when it comes to games.  POWDER is a Roguelike game, which means that you kill monsters, gain levels, zap things with magical wands and generally get involved in all sorts of fantasy RPG shenanigans.  Classic Roguelikes of the likes of Nethack and Angband are purely ASCII based and (in my opinion) aren’t very accessible.  With POWDER the entire game can be played using the mouse, and the keyboard shortcuts can be picked up bit by bit once you’ve got into the game.

It has been designed with hand held consoles in mind, but can be downloaded and played on Windows and Linux alike from the author’s web page.

Behind a somewhat simplistic facade is a deep and complex game that will take you a very long time to master. Each time you play (and die) there is something new to be learned for the next time you delve into the dungeon.  The first time I played the game indicated that I was hungry.  I decided to eat a slug that I had just killed, only to be poisoned and die.  Naturally I avoided doing that in subsequent attempts.  There is even a tutorial to help you get started.

A wiki exists for impatient players who don’t want to find everything out for themselves.  I still haven’t figured out how to stop myself from starving to death once I get a bit deeper into the dungeon.

Update: Two interesting things I also think are worth mentioning.

Roguelikes aren’t purely fantasy based.  There are a great deal of science fiction based games, include a version of Doom implemented in ASCII.

Also, there is a yearly competition where programmers try to create a fully playable Roguelike in just 7 days.  The short time encourages programmers to try out and explore new ideas and end up with a finished product at the end.


Nov 17 2009
a green leaf

Health and safety at work

This is a photo I took in Bejing a few years ago and have been meaning to upload it for ages.  The picture is of a couple of guys repairing a telephone line (or some sort of overhead cable).  The work was undertaken in the face of oncoming traffic.

ladder_guy

Street work in Bejing


Nov 16 2009
a green leaf

Introducing JTestConnect

logo

A couple of months ago I finished the first version of JTestConnect. It is a tool for supporting development teams with their unit test strategies.

You can annotate your interfaces/classes with annotations describing how the object should be tested. The tool then sits in the build process and can interrupt a build if test classes/methods are missing.

Ideally, this would be added to a Continuous Integration build system to enforce test coverage of important classes.

A more detailed description of what it does can be found on the project home page.


Nov 16 2009
a green leaf

Detecting HTML5 Features in Javascript

How can you detect if your browser supports HTML5 features in javascript?  Here’s how:

function isHTML5CanvasSupported() {
    return (typeof HTMLCanvasElement != 'undefined');
}

function isHTML5VideoSupported() {
    return (typeof HTMLVideoElement != 'undefined');
}

function isHTMLClientSideDBSupported() {
    return (window.openDatabase);
}

Have fun!


Mar 9 2009
a green leaf

A Nice Place For A Swim…

A nice place for a swim!

Near to Tikal in Northern Guatemala


Mar 6 2009
a green leaf

Using EasyMock to Create Stub Objects

There are two competing philosophies with regard to unit testing strategies; state based testing and behavior based testing. In state based testing we configure a starting state, execute a test method, and then examine the resultant state/returned result. In behavior driven testing we ensure that our test object collaborates with its dependencies in an expected way.

Continue reading


Feb 7 2009
a green leaf

Security Conference 2009 Protests

Some photos from the growing crowd protesting the Munich security conference.  The pictures were taken from Marienplatz (where the town hall is). The birds eye view pictures were taken from the upper floors of a bookshop in the square. I had been chatting away to a pair who were also enjoying the same vantage point. I mentioned that I had asked myself whether or not it would be a good idea to go taking pictures of all the police and vehicles and what ever else. One of them asked me “why?”, and I answered that “you never know”. He seemed irritated at my apparent mistrust of the police. I don’t mistrust the police (at least not in Germany), but you can always be in the wrong place at the wrong time. As I walked away my girlfriend pointed out that they both had hidden walkie-talkies and were actually under cover police officers. I went to the next floor up to get some more photos and noticed another man standing taking a picture with his mobile phone. After a few seconds of me pointing and clicking (and chatting) I heard his hidden radio (turned down to not attract undue attention). There were two more men on the top floor idly chatting with a bag at their feet and huddled against the window blocking the view. I received a strange look as I approached them as if their fellow officers had radioed up for them to look out for a suspiciously chatty Englishman.
g8_1g8_2g8_3g8_4
Continue reading


Feb 5 2009
a green leaf

Random Number Generator

Random Numbers

Random Numbers