What is Lazy Load ?
Loading different contents of the page after the initial page load is called Lazy loading. This is contrary to most common method called Eager Loading.
Why should i care about ?
When a developer starts to build a page for a Org, they might have few requirements. But, as days pass on, they may get more requirements from customers & keep adding features one by one. Most of the time, Controller needs to do heavy lifting during its construction, that means it will have more logic placed inside constructor. This will make page loading time way high & gives very bad performance.Where it will be useful ?
When you want to make Heavy DML calls involving huge number of records or having complex Apex processing, then, it's bad idea to have that logic in constructor.How to do it ?
Ideally, Constructor should be used to initialize the objects to bare minimum, that means just initializing to empty object. In another view, it must have only logic to display very minimum components to the user, other stuff needs to be handled through separate action functions.For example, if you are displaying Table of data, its better to use pagination with small number of records set number. If you are displaying record details, you can display overview information & fetch more details if user press for 'more details' button/link.
No comments:
Post a Comment
Thanks for reading my blog !