What is streaming?

Streaming is a way of saving objects so they can be restored at a later time. Polymorphic streaming of objects to memory and to files accomplishes much of the same work you might ordinarily do to save user data to files or to shared memory. However streaming is much easier. Streaming lets you avoid the headaches regarding details of encoding type information along with data into a file or memory block. Normally you would have to mix information about data types with associated data manually so that you can recreate the original source objects from the saved data. With this traditional approach much effort goes into design decisions about the structure and format of data files--a form of persistent memory.

CommonPoint streams relieve you of the burden of specifying memory and file formats. The benefit of an object-oriented operating system is that each object you create knows its type. Streaming operators use this knowledge to automatically embed type information along with data files and memory blocks whenever you save any object, or collection of objects to a stream. For example, you might want to save the data associated with a user application, such as a word processor. One way to do this is to stream the user data (text, associated attributes, and properties) to a disk file. This makes it possible for the user to quit the word processing application, and even to turn off the computer, and later return to open the data file and resume work at the same point at which the data was saved.

Say, for example, the data inside a drawing diagram consists of a collection of points, and a collection of lines. These collections could be streamed to a disk file to preserve them beyond the current editing session. This happens behind the scenes when the user issues a File/Save command. The user can come back later (even after the computer has been turned off and on again) and reinstantiate identical instances of the collection of points and the collection of lines that was preserved when the application was saved. This happens behind the scenes when the user issues a File/Open command.

Of course, you don't have to use streams to preserve user data. You can open a file manually and follow a predetermined format to save the state data of a document for a particular application. But this is too much work. One of the primary roles of object-oriented programming is to hide details of implementation from clients of frameworks. Streams provide convenient abstractions for preserving complex data sets as persistent objects.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker