4/15/2023 0 Comments C class initializationWhen you have an object that is expensive to create, and you want to defer its creation until after other expensive operations have been completed. By using Lazy to declare the Orders object for lazy initialization, you can avoid wasting system resources when the object is not used. If the user never asks to display the Orders or use the data in a computation, then there is no reason to use system memory or computing cycles to create it. For example, assume that you have in memory a Customer object that has an Orders property that contains a large array of Order objects that, to be initialized, requires a database connection. When you have an object that is expensive to create, and the program might not use it. (For this topic, the terms lazy initialization and lazy instantiation are synonymous.) Lazy initialization is primarily used to improve performance, avoid wasteful computation, and reduce program memory requirements. Lazy initialization of an object means that its creation is deferred until it is first used.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |