Not to load code modules into memory until you are sure you are going to be required. Example:
I am having Category and Sub-Category. Category can hold list of Sub-Category, but this sub-category is not require every time. I’ll load sub-category when it is required. I am using following code to achieve this.
public class Category
{
// Other Geter Seter..
private List<SubCategory> _subCategories;
/// <summary>
/// Sub Categories
/// </summary>
public List<SubCategory> SubCategories
{
get
{
//Lazy Load
if (_subCategories == null)
_subCategories = GetSubCategories(this.ID);
return _subCategories;
}
set { _subCategories = value; }
}
}
I’ll not fill list of sub-category in default load of Category object (cunstructor or some Load method) instant of I’ll load list of sub-category when it is acthuly required.
http://www.martinfowler.com/eaaCatalog/lazyLoad.html
ASP.NET Interview Questions |
C# Interview Questions |
.NET Interview Questions |
Dot Net Interview Questions |
VB.NET Interview Questions |
Oracle Interview Questions