Lazy Loading in Windows Forms
I have a question: can we use the Lazy Loading pattern in Windows application?
Appreciate if someone would explain this with some examples.
Jebby Philip, Mar 15, 2010
Another example is when you need to access a parent object in your object graph. For example, if you have an Invoice and you want to know the Customer of this Invoice, it will be more easy to say :
so, in this case you should prepare you Invoice class to load the Customer Object in the getter property like :
I hope this helps
Redha Reghioua, Apr 25, 2010
Thanks Shiva, Juan, Syed
Jebby Philip, Mar 24, 2010
Lazy loading is just a fancy name given to the process of intializing a class when it's actually needed. You might already be doing it.
For example suppose you are maintaining a collection of orders on the form and it's a class level variable, which you will fill thought out the life time of the form.
Since you know that you are going to use this collection you may say while declaring at form level
private List<orders> myOrders = new List<orders>();
or you may choose to lazy load it
private List<orders> myOrders;
and then in you form when you add the first item you do this
if ( myOrders == null)
myOrders = new List<orders>();
Syed Saqib Ali Tipu, Mar 20, 2010
Yes, you can. Lazy loading is nothing but deferring the loading of constiuent objects (referenced objects) of a class until it is required/accessed. May be this would help: http://www.lhotka.net/Article.aspx?id=48548dc3-3b64-4bb3-bc84-9476b8f77600
Siva M, Mar 19, 2010
Mar 13, 2010