Monthly Archives: January 2011

3 posts

Name that pattern

In my day to day work I encounter several interesting programming pattern that I don’t have a name for. Maybe you have?! So name the following pattern:

[sourcecode language=”java”]
if ( !trans.getWeights ().isEmpty () )
{
final Collection<Weight> weightList = trans.getWeights ();
WeightVo weightVo = null;
for ( final Weight weight : weightList )
{
weightVo = getWeightDao ().toWeightVo ( weight );
break;
}
truckVo.setWeightVo ( weightVo );
}
[/sourcecode]

While one can argue if this one-liner is more readable and understandable:

[sourcecode language=”java”]
truckVo.setWeightVo ( trans.getWeights().isEmpty() ? null : getWeightDao ().toWeightVo ( trans.getWeights().get ( 0 ) ) );
[/sourcecode]

The following definitely is:

[sourcecode language=”java”]
if ( !trans.getWeights ().isEmpty () )
{
truckVo.setWeightVo ( getWeightDao ().toWeightVo ( trans.getWeights().get ( 0 ) ) );
}
[/sourcecode]

Combo viewer requirements

Today I tried to create a combo viewer in Eclipse with a different approach than the it seems the widgets was designed. I have an object which has to main properties an ID and a descriptive name. While this is nothing unusual following requirements seems to be:

The list of the combo box should show the label while the text input field of the combo box should show the id of the object. Using Eclipse Databinding this seems to be an impossible task (if you know a way please post it at stackoverflow). Continue reading

Hello world!

After upgrading my server and cleanup up stuff I thought it would be nice to work a little bit on the homepage again. Since iWeb seems to be stuck and I am working mostly on Linux now I though it would be interesting to give WordPress a try.

Let’s see what happens …