Perhaps the statement best practice was a little strong, or at least
taken out of context.
I was aiming towards the idea that for value transfer objects -
effectively structs from C/C++, public finals are a perfectly
acceptable option and in my opinion preferable to getters for the same
purpose. For these kind of immutable value objects, they introduce
less chance that you will get anything but the immutable values for
those fields, the principle of least surprise. On top of that, you
save a bunch of boilerplate as well.
Since the references are final, there seems little to be gained by
making them private and restricting access through getters unless you
want to somehow add behavior to the accessor methods - and if you do
that you probably aren't wanting value objects in the first place.
Of course, as mentioned, this idea definitely works out best with
final references to immutable objects, but will behave the same as
getters even if the objects referenced are not immutable - you still
end up with the same references from the direct access or from the
getter, what you do with it after that is your choice.
Scala has uniform access for properties, so that eliminates the
distinction (getXXX methods are only generated when you need
compatibility with JavaBeans for some reason). For everything else
though, I would still claim that final publics are a good idea when
all you want is a "struct".
Cheers
Dick