On Wed, 19 Aug 2020 at 13:48, Nathan Xu <nathan.qingyang.xu(a)gmail.com> wrote:
Thanks for the null-check tip! I appreciate that.
As a matter of fact, NPE issue still bothers us a lot. This recent PR from the community
is another validation:
https://github.com/hibernate/hibernate-orm/pull/3499How to
systematically combat NPE is a good topic and still highly relevant. Maybe we can talk
about it later.
I didn't anticipate we should abandon the 'lazy initialization' pattern
totally (even when we limited its scope to ArrayList constructed by default constructor).
My point is to raise the awareness that since JDK7, ArrayList has a lazy-initialization
feature built-in already. We still pay the cost to create an empty ArrayList (without
allocating 10 elements in advance), but the overhead might be worthwhile for it leads to a
more elegant and maintainable codebase.
Noted, thanks. But I still recommend to keep this pattern as the
overhead has been proven to be very significant in some cases. We'll
just need to be careful with any change, but that's always the case :)