[hibernate-dev] Re: Regarding lazy initialization of ArrayList

Sanne Grinovero <[email protected]>
Newsgroups gmane.comp.java.hibernate.devel
Message-ID <CAFm4XO2aB22RuGGsob0UcVKYjgF1WZ9eCxAb_y0CjcAacWdevw@mail.gmail.com>
On Wed, 19 Aug 2020 at 13:48, Nathan Xu <[email protected]> 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 :)
_______________________________________________
hibernate-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.