If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Wednesday, April 28, 2010

Object Oriented Javascript

Nowadays you'll find many ways to program Object Oriented in javascript. But if you'd like to do it without depending on some third-party javascript library below you'll find an example.




Now you can create a new Lion object which inherits all properties from the function (class) it extends.

Friday, April 23, 2010

xslt1.0 challenge

Someone on the xslt mailing list wanted to build a nice html table based on searchresults but the problem was not all searchresults had the same data.

I decided to give it a go and actually made the challenge a bit more difficult ;-)

Input:


Expected:


As you can see the tableheaders are sorted and the datarows should of course match up with the corresponding headers.

Thursday, April 8, 2010

Miljoenenjacht

Today I heard about a game called 'miljoenenjacht' on the radio. You basically have to answer some questions online which will gradually reveal the ZIP code where the Nationale Postcode loterij has hidden a suitcase full of money.

Anyway... I thought of checking it out and i answered the first question correctly. This revealed 2 numbers of the zip code pattern "[0-9][0-9][0-9][0-9] [A-Z][A-Z]".

Since i didn't have any idea what postcodes are available in the Netherlands I downloaded some CSV files from the internet which contained following information
- Zip code
- City Name
- Street Name

To be able to query those files by a specific zip code pattern I wrote following diry hack :-)







The output of running the main method:

The pattern resulted in 1319 hits.
7908 AA | Hoogeveen | Mortonhof
7908 AB | Hoogeveen | De Weide
7908 AC | Hoogeveen | Zuidwoldigerweg
...

Tuesday, April 6, 2010

When enums are not an option

I had to write some code for JDK1.4 which does not support enums. Below you will find some way to achieve enumeration like functionality.

The first thing I did was creating an empty marker interface.


Next I wrote a DataTypeFactory which exposes final DataTypes.