Sunday, January 25, 2009

Binding to values

In a Guice module, binding a class to a specific value is directly supported. How about Spring? You have to provide a FactoryBean.

Saturday, January 24, 2009

TestNG

I had read about TestNG, including the book, and even played a little bit with it. But, until today, I had never set it up as the testing framework in a project instead of JUnit.

Why have I taken this step? Well, I have felt the need many times to keep state between test methods to simplify them (and if you add dependent methods, also in TestNG, in order to chain them), even though I understand JUnit's reasons for not providing this functionality.

So, TestNG has earned itself another "testing" round :).
 

Living on the edge...

As predicted by Murphy's Law, if you need some feature (or a critical bug solved) from a third-party library or framework, it'll be planned for the next version.

I faced this truth again a few weeks ago. I was looking at Guice for some specific dependency injection needs... and type converters where planned for 2.0...


Friday, January 23, 2009

A Domain Driven Design snippet

This post in my reading list reminded me of Domain Driven Design (see the book). I've always liked the idea of strong Domain Models that lead to better encapsulation and more information hiding.

What's the problem, then?. For many (even CRUD) applications much business logic involves non-trivial repository access. So, you need your bussiness objects have a reference to the repository. This should not be a problem for your favorite dependency injection engine.

At this point your favorite ORM tool chimes in, taking control of the lifecyle of your domain objects... Well, there are some AOP-based solutions, but I don't see them as long-term general solution yet.

Sunday, January 18, 2009

Null-default and Null-safe operators

Today I've been having a look at Stephen Colebourne's proposal for null-handling in Java 7 (see this post for a summary).

I really like this proposal:
  • It is only syntax sugar, like many of the changes introduced in Java 5.
  • It really helps to reduce boilerplate code.
The main drawback I see is that heavily chained uses of the null-safe invocation operator may lead to some debugging knightmares (which invocation returned null?) unless some support is added to IDEs.