Author Archives: benji

Typesafe Hibernate POJO Queries without code generation

Hibernate is great, but often one has to specify queries as HQL in Strings, or as criteria which allow building of invalid queries.

It would be great to use the java type system to help enforce correct queries. I am aware of some tools to do this, but all the ones I have seen require either [...]

Posted in Java | 2228 Comments

Java Abuse: Inline instanceof

One annoyance in Java is having to do instanceof checks on multiple lines. e.g.

if (object instanceof Foo) {
Foo foo = (Foo)object;
foo.foo();
}

While this is often a sign of a design failure, there are times when instanceof checks are required often due to framework constraints etc. The above is [...]

Posted in Java, Uncategorized | Tagged | 4399 Comments

Netbeans on n900

I meant to post some time ago about how great the n900 is for java development. Not only can one install OpenJDK, but Netbeans is even usable. It’s pretty easy to get running. Just install openjdk6 in the application manager. Then download and run the netbeans installer.

It even runs at quite a reasonable speed if [...]

Posted in Uncategorized | 3711 Comments

Java Abuse: public static void main was not invented here.

Normally a command-line Java application will have an entry method that looks something like:

public static void main(String… args) {
/* Code that launches the application/deals with command line params here */
}

This is far too easy, there must be a way to NIH it ¬_¬. There are a few annoyances with the public [...]

Posted in Uncategorized | 3919 Comments

openSUSE conference – Software Portal Talk

Here are my notes from the software portal talk Pascal and I gave yesterday at the openSUSE conference.
The slides we used are also available.
What is the Software Portal?

Software Portal is a free-software web-application that runs as a service on on opensuse-community.org. It provides both a web-ui and an API. It is possible you are already [...]

Posted in openSUSE | 3746 Comments

Switzerland

I got back this week from holiday cycling and walking in Switzerland. I cycled down from Basel in the north via Bern and Interlaken to Fiescheralp. Then back via Luzern and Zürich.
Fiescheralp is next to the beautiful Aletsch Glacier

I stayed in a chalet here for a few days with family and did some climbing and [...]

Posted in Holiday | Tagged , , | 4199 Comments

Java Abuse – Currency Pattern

Here’s a sillier one from last night…
People often complain about not being able to return multiple values from a method in Java. I can’t see a good reason for wanting to do this, but some do.
The example I was given was wanting to do:

int foo, bar, baz; list(foo, bar, bar) = func(ponies);

Where func(ponies) returns 3 [...]

Posted in Java | Tagged | 1536 Comments

Java Abuse – Ternary Try/Catch

We often discuss Java limitations on IRC and try to come up with (sometimes silly) workarounds. Unfortunately after time passes it’s often easy to forget the outcome, and lose code snippets. So I thought I’d start blogging some of them so I don’t lose them, and other people might suggest other ways of doing things [...]

Posted in Java, Uncategorized | Tagged | 3478 Comments

Software Portal Preview Available.

In the last couple of weeks I’ve had some time to work on the software portal project for the first time for a while.
There is now a test snapshot that you can play with if you wish, and help find bugs.
Please do have a play and leave comments here or file a bug report under [...]

Posted in Uncategorized | 690 Comments

Snow

This morning we had an unusual amount of snow here, more than we’ve had in my lifetime. Most public transport was suspended and the people attempting to drive were quickly getting stuck and sliding all over the place.
Motorists were making the classic motorist error. They’ve got too much power. I’ve got half a horsepower on [...]

Posted in Uncategorized | 4295 Comments