Lazy initialization

After two lengthy discussions, a section about a lazy initialization pattern should present a comfortable change. This pattern appeared in the Gang of Four book under the name of virtual proxy, which virtually nobody is using today. Lazy initialization, on the other hand, has become a common household name.

Lazy initialization is a very simple pattern that merely states whether an object is not always required, creating it only when it is needed. We would use this pattern on two occasions: when the creation of an object or its initialization is a slow process, or when the very existence of the object signifies something.

Whenever I go somewhere with a car, I have to take into account the small possibility that the car ...

Get Hands-On Design Patterns with Delphi now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.