let's play TDD, tackles closures in java

Florian Weimer fweimer at bfk.de
Thu Dec 16 00:30:46 PST 2010

* Llewellyn Falco:

>> Yes, those 8 lines of code do seem easy compared to
> boolean fired = false;
> model.addTableModelListener(#{e -> fired = true});
> model.doThing();
> assertTrue(fired);

We can turn this into:

final BooleanReference fired = new BooleanReference(false);
model.addTableModelListener(#{e -> fired.setValue(true)});

I don't even think that this will cause interoperability problems
because the *Reference helper classes are used only locally, so it
doesn't matter that each project will have their own set of such

It would be preferable to support this programming style directly in
the language, but the alternative approach is not so bad that people
feel an urge to use a javac fork.

Florian Weimer                <fweimer at bfk.de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99

More information about the lambda-dev mailing list