Stephen Colebourne's blog: bestpractice
Actually writing VALJO classes is boring and tedious. The rules and implications need to be carefully thought through on occasion. Some projects provide tools which may assist to some degree.
Joda-Convert provides annotations for @ToString
and @FromString
which can be used to identify the round-trippable string format.
Joda-Beans provides a source code generation system that includes immutable beans. They are not instant VALJOs, but can be customised.
Auto-Value provides a bytecode generation system that converts abstract classes into immutable value objects. They are not instant VALJOs, but can be customised.
Project Lombok provides a customised compiler and IDE plugin which includes value object generation. They are not instant VALJOs, but can be customised.
In general however, if you want to write a really good VALJO, you need to do it by hand. And if that VALJO will be used by many others, such as in JSR-310, it is worth doing correctly.
Read full article from Stephen Colebourne's blog: bestpractice
No comments:
Post a Comment