Monday, August 30, 2010

Lazy initialization

http://www.javapractices.com/topic/TopicAction.do?Id=34

Lazy initialization of a field may be useful when both of these conditions are true :

* the field is particularly expensive to create
* the field has an optional character, in the sense that it may or may not be of interest to the caller

In this case, the construction of such a field may be deferred till the moment it is actually required. This increases performance by avoiding unnecessary creation of expensive objects.

No comments:

Post a Comment