Iterators for Accessing Data from Procedural Systems for Representation as Objects
Original Publication Date: 2000-Jun-01
Included in the Prior Art Database: 2003-Jun-12
One of the problems when accessing procedural systems and representing data in those systems as objects is that some calls to a procedural system return data representing multiple objects. In addition, these calls may return subsets of data representing only a subset of the objects at a time, requiring multiple calls to retrieve the entire set of data for all of the objects. In some cases the list of objects can be very large and only a small number are necessary. A naive approach to solving these problems is to retrieve all of the data and instantiate all of the objects at one time. However, this approach can be time consuming and, if only a subset of objects are required, unnecessary work may be performed. This disclosure describes a solution for solving these problems of retrieving data from a procedural system. An iterator can be created that uses the techniques of this disclosure to create objects only as they are required. Since the procedural system may return data for the objects in subsets the iterator also handles these subsets. This disclosure describes a solution to the described problems by introducing three classes to be implemented by a programmer. Figure 2 shows an example of a specific implementation of these three classes as an intelligent iterator, and Figure 3 shows an example of the use of the iterator of Figure 2. In this example the data for the objects is displayed as a list of items on a sequence of screens. The classes follow the traditional command pattern. The first command provides the calls to the procedural system to take it to the point where the data that represents a set of objects can be obtained. This command is called "start". The start command may also provide some set of data that represents objects itself if the separation between getting to the point of listing the data is not completely distinguished from where the data starts. In this case objects will be created with that data. The start command is called when the iterator is initialized. The next command is the replenish command. This command traverses to the next piece of data and then takes this data and creates objects for it. Typically the next call on an iterator will check if there are any objects that have been instantiated and if not then call the replenish command to get the next set of data. The replenish command may be called a number of times.