Lazy Load Pattern


Definition
Lazy loading is a software design pattern where the initialization of an object occurs only when it is actually needed and not before to preserve simplicity of usage and improve performance. In another word "Lazy initialization of an object means that its creation is deferred until it is first used."

Applicability
  • When you have an object that is expensive to create, and the program might not use it.
  • When you have an object that is expensive to create, and you want to defer its creation until after other expensive operations have been completed.

Consequences
  • Prevent system memory or computing cycles usage when there is no reason to do it.
  • Improve the startup performance of the program

Downsides
  • When initializing there can be some lag when things are getting loaded into memory.
Sample Code
The following code snippet demonstrates how lazy loading works:


Comments

  1. Load up on sugar in Sweet Bonanza™, the 6×5, pays anywhere, tumbling videoslot. “Original machines of this caliber don't come to public sale typically, and this one is the best authentic Caille Roulettes we now 코인카지노 have seen. It deserves the description ‘best of the best,’” stated Morphy’s CEO Tom Tolworthy, a coin-op expert who also cataloged the November 3-5 public sale. The stately Caille machine is anticipated to make $200,000-$300,000.

    ReplyDelete

Post a Comment

Popular Posts