Archive for November, 2006

A new way to init Java objects!

Well you learn something new every day. Initializing Java objects can be a chore, and especially when initializing static data in collections, where the collections are fields of another object.

Well some smart cookie found a way to use the standard anonymous class mechanism of Java to do initialization that means you don’t need to specify the name of the object, and can bind the initialization code to the field definition. Basically when you construct the object you do so as an anonymous class and use the instance initializer block to access fields or methods of the object.

Where in the past you might do:

public class Test {
private List creditCards = new ArrayList();
{
creditCards.add( "VISA");
creditCards.add( "MC");
creditCards.add( "AMEX");
}
}

You can do:

public class Test {
private List creditCards = new ArrayList() {
{
add( "VISA");
add( "MC");
add( "AMEX");
}
};
}

It’s pretty cool. The only sideeffect is that the creditCards field will be of a type that extends ArrayList, i.e. something like Test$1.

Who would have thought we could find out something new about fundamental features of Java after all these years?

Note: Sorry about the crappy source formatting, WordPress doesn’t like preformatted text.

  • Twitter
  • Slashdot
  • Delicious
  • Evernote
  • Share/Bookmark

21

11 2006

Grails 0.3 released

Graeme Rocher released Grails 0.3 today. Grails is a rapid development framework in the mould of Ruby on Rails but with Java and Groovy at its core, with best of breed Java tools built in, including Hibernate and Spring.

Version 0.3 resolves a mammoth 115 issues and adds powerful new features like many-to-many relationships, custom validators and a great number of other Hibernate/ORM related improvements and fixes. It represents a major improvement over 0.2.x in terms of quality and the elimination of many niggles that were tripping people up when they first started using it.

It feels like Grails’ momentum is building rapidly and in particular Graeme is to be thanked for the hard work he has put in. We are getting more contributors coming on line now and lots of new issues being created, which is a sign of success!

There are major plans afoot already for version 0.4…

  • Twitter
  • Slashdot
  • Delicious
  • Evernote
  • Share/Bookmark

09

11 2006

Jira could do with “Split version” option for Roadmap

I often find that when reality catches up with us, we need to bail out a bunch of issues that just can’t be fixed in our current release version unless we introduce unacceptable delays in the release.

When this happens I have to use “Bulk change” in Jira’s issue navigator to locate the subset of issues that are going to be “bumped” and change their Fix-for version to the next version.

However sometimes we need a new version inbetween the current and next, to handle those “bumped” issues. i.e. version 1.0.14 was going to have X and Y in it, and 1.0.15 is going to have P and Q in it. After bailing out issues that can’t be fixed for 1.0.14 we really need 1.0.15 et al to be moved up a revision number (to become 1.0.16 containing P and Q and so on), and a new 1.0.15 created containing just the issues bailed out from 1.0.14.

Because Jira is not version-number aware currently, it cannot do this. It could currently offer a “Split version” option in the Version Management page, so you could instead of Releasing make it “Split” the version into resolved and unresolved issues, and prompt for a new version number to sit in between this and the next release. So we could enter “1.0.14b” for example.

It’s not perfect – auto version numbering would be much better – but it would do until that comes.

  • Twitter
  • Slashdot
  • Delicious
  • Evernote
  • Share/Bookmark

08

11 2006

Biofuels are a false hope

I have long harboured concerns about biofuels. Primarily I was concerned that, being used for diesel engines, you would still see large amounts of sooty pollution particles, which having lived on a busy road with trucks passing I can tell you is less than pleasant.

George Monbiot’s book HEAT exposes very well the fallacy of bio-fuels for the UK if not the world:

  1. There’s nowhere near enough agricultural land of the quality needed to produce enough bio-fuel for the UK using UK farms.
  2. Thus, bio-fuel crops would need to be imported.
  3. This importing wastes more energy.
  4. This imported fuel harvest will come from the cheapest source, typically poor nations.
  5. The poor nations will therefore experience competition for their agricultural land such that they will not be able to grow enough food for their own people, as we will inevitably be able to pay more for their grain to use as fuel than they will to feed themselves.

The last point is the killer, literally. Car driving, based on bio-fuels, will cease to become something that just wrecks the environment, but will become something that directly wrecks the lives of hundreds of thousands of people.

Don’t believe me? Check out this report from just a couple of days ago, into the world grain stocks and how we are now exceeding global grain supply.

Deforestation for palm oil, Indonesia

As if this wasn’t bad enough, the cheapest source of biofuel currently is Palm oil. The rising demand for this is already causing the destruction of vast swathes of forest in Malaysia, Sumatra and Borneo. Monbiot successfully argues that biofuels, except those derived from used cooking oils, are worse than oil.

The only solution to personal transport (i.e. cars and bikes) is electric power drawn from sustainable sources. Even then we have the issue of ever increasing traffic and roadbuilding to contend with.

  • Twitter
  • Slashdot
  • Delicious
  • Evernote
  • Share/Bookmark

05

11 2006