To apply Short Views means accessing only as many rows of a selection from a database as can be presented on a single screen
Given the list box problem in the Narrow Views pattern you have designed a Physical View that contains exactly the data for filling the list box. Users still complain that filling a list box can take up to 20 seconds for the best customers. Good customers may have hundreds of open orders associated to them.
How do you speed up filling of list boxes and how do you prevent unnecessary data from being loaded into the list box?
· Performance: The query that is used to fill a list box will often yield far more records than there are lines in a dialog box. Many list box classes are therefore based on a container that can handle an arbitrary number of list box items. Fetching a large quantity of records at once will have two implications: Often you might only want to see a few pages of information. In such a case a dumb query causes enormous database load. You are also blocking bandwidth while the list box is filled with lines you cannot see and worst - the user is gazing at a hourglass pointer.
Load data in chunks that allow a reasonable response time. A rule of thumb is 30-50 records for C/S system. This is equivalent to two times the number of lines in a list box.
There are two possibilities to implement the fault mechanism when the user has come to the end of the sequence of already loaded objects. If the programming environment supports database cursors (see Database Cursor for Selects [Sie96]) the list box container will simply ask the cursor for more records. If you are working with a transaction monitor that does not allow you to have open cursors over dialog steps you have to issue a new query starting from the last record you have in a listbox and yielding no more records than the fixed number you want each time you access the database.
Performance: Using this scheme results in better response times for the user and less load for the database. Some more code is needed to implement a container that asks the database for more records. This code can well be encapsulated in a smart container behind the list box class.
The easier variant to handle block reading is covered by the Database Cursor for Selects Pattern [Sie96]. The Result Streams Pattern [Bro+96] covers containers that send a request for more data if the user reaches the end of the current set.