In computer programming, lazy initialization is the tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed.
This is typically accomplished by maintaining a flag indicating whether the process has taken place. Each time the desired object is summoned, the flag is tested. If it is ready, it is returned. If not, it is initialized on the spot.
See lazy evaluation for a general treatment of this idea. In heavily imperative languages this pattern carries hidden dangers, as does any programming habit that relies on shared state.
Read more about Lazy Initialization: The "lazy Factory"
Famous quotes containing the word lazy:
“Take us generally as a people, we are neither lazy nor idle; and considering how little we have to excite or stimulate us, I am almost astonished that there are so many industrious and ambitious ones to be found; although I acknowledge, with extreme sorrow, that there are some who never were and never will be serviceable to society. And have you not a similar class among yourselves?”
—Maria Stewart (18031879)