Introduction to Protos

Protos Provide Template Reuse

On Newton, protos are the mechanism for reuse. Anything that you want to use in multiple templates, be it functionality or visual appearance, you can capture in a custom user proto. Protos provide for reuse of code in much the same way that libraries do in many other programming environments.

This should also lead you to a clearer understanding of application design on the Newton. You do not have multiple templates with identical slots, rather you gather common slots together into a proto. Then, you use such protos in your templates. You capture uniqueness in your templates and commonality in your protos (see FIGURE 7.4).

Now, consider a simple case. In FIGURE 7.4, there are three templates that have several duplicate slots and some unique slots. Each template creates a view where the user can write a list of items (groceries, errands, or chores). Instead of creating three similar templates, the proper approach would be to create one user proto that contained all of the common slots. That user proto would be referenced by each template via a proto slot. In the templates, you would set unique elements, such as the screen location of the view and the list label: chores, errands, or groceries.

FIGURE 7.4 : Creating a user proto to capture commonality in a number of templates.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996