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 will not start. If that happens, I call my mechanic. That's lazy initialization.
Doing it in a classical object-oriented way would be entirely...
Doing it in a classical object-oriented way would be entirely...