Delayed instantiation is an effective performance technique typically used on hidden Pages in Page Frames.
It works like this:
- Design your Page Frame as usual.
- Save everything on each page but the first visible page as a class, one class for each page.
- Delete the contents of all but the first page in the Page Frame.
- In the
Activate method of each page, check
This.ControlCount and, if zero (i.e. the page is being activated for the first time), then use
This.Addobject(cName,cClass) to create the controls which are only henceforth needed for display.
- The Form instantiates much more quickly because only the first Page of the Page Frame is built.
- This Pay As You Go behavior is especially beneficial if the user never navigates through the subsequent pages.
- A downside: first activation of subsequent pages takes a little longer -- this is the Pay part of Pay As You Go.
Don't worry that the first activation in the IDE seems longer than you might like, it'll be fine once you compile it all into an EXE. -- Mike Yearwood
I base all my interfaces on containers. The containers are only added to the forms when the forms are Activated so you can create a number of forms quickly like a form set. The interface is only added if you actually display the form. Like the pageframe idea above this is another pay as you go scheme. Simon White
You can combine these 2 approaches very effectively : first, as Simon points out, design containers that can be then loaded onto a pageframe on whatever you have designed as a "standard" form (e.g. navigation buttons etc). Put a disabled Timer control on the form. The Init() of the form then just loads the container for Page 1, finishes by enabling the Timer. Use the Timer's Timer Event to load the other containers. I used this approach a few years ago when I worked on a system which allowed users to change label captions and whether data-entry fields were required or not (by editing a data dictionary), which increased each individual control load time quite a bit. Effectively, the load time the user felt they were experiencing was reduced considerably (on a 6 page form, it reduced to about a quarter). Since we kept the names of relevant containers in a separate client-specific data file, it also gave us a lot of flexibility about which containers we loaded for any one client. Ian McColm
Category Performance Category Application Design
( Topic last updated: 2007.12.18 08:53:13 AM )