Hi, I'm Dan Halberd, and I work for the Office Systems Division
of the Xerox corporation.
I'm going to tell you about a technique of programming
called programming by example.
The basic idea of programming by example
is that the user writes a program
by giving you an example of what the program should do step
by step.
The program is written in the user interface of the system
that the user is trying to program.
Basically, programming by example is do what I did.
I'm going to demonstrate programming
by example in a simulation of the Xerox 810 star office
information system.
Now in order to illustrate programming by example,
I'm going to write a program to do exactly just what I did.
That is, move the icon named Zion out of the Parks folder.
And now I'll select the program icon, and open it.
In the window header at the top of the program icon
are several commands that have to do with programming.
There are command start and stop recording,
which get the system to start and stop remembering
the actions that I'm doing.
There are also some commands for single
stepping a program that's been recorded,
and a command to record--
to run a program that's been recorded.
So now in order to record this program,
I'll press to start recording button,
and an extra little window comes up
that reminds me that I'm recording.
So now I'll do exactly what I did before.
I'll go over to the Parks folder, I'll open it,
and now I go down and select the icon named Zion,
and move it out of the folder onto the desktop.
As I'm doing each of these actions,
the system is making a transcript of what I'm doing
and it's appearing in the program window.
Now the last thing to do is to close the Parks folder,
and since that's the last step in the program,
and I'll now stop recording.
And the system cleans up the program a little bit
and takes out those ellipses.
Now let's try this program and see if it works,
and what it will do will happen pretty fast.
Parks folder opens, Zion gets moved out,
and the Parks folder closes and that's it.
I'd like to write a program that takes out all the documents
that have canyon, the word canyon, in their name,
and I can do that by modifying the program that I have here.
And now we'll go back and edit this data description again.
I'll select it, and open this window.
And now I want to go back to looking for this document using
some name pattern.
So I'll switch back to name, but I
don't want to look for the icon name Grand Canyon.
Instead, I want to look for an icon that
has the word canyon in it.
I'm looking for a name that has the word canyon in it.
So I'll type asterisk canyon asterisk which looks for any
name with the letters c-a-n-y-o-n inside.
Now I'm done, so I'll press the Done button here,
and again, the program will change.
And now I'm looking for any document with the word
canyon in its name.
Now this program moves only one document out
of the Parks folder, but I want to move
all the documents that match this pattern out of the parks
folder.
So what I can do is add a loop to this program.
I can select the statement that I want to be inside the loop,
and then wrap the statement in a loop using the Repeat
command in the pop-up menu.
All right, now the move statement is inside a loop,
and here's this loop that repeats something over and over
again.
And I want to say that I want to use a particular description
repeatedly.
Well, it doesn't know which description I want,
so I have to fill that in.
So I'll select the description I want,
and copy it and drop it in this blank space.
All right, now this program says repeat the statement, this move
statement, and repeat it over and over again using everything
that matches this description.
That is, every document with the word canyon and its name.
So let's try to run this program.
Press run, and the parks further opens,
and it starts taking out documents.
It takes out Bryce Canyon, Grand Canyon, and Canyon Lands.
And indeed, those are the three documents with the word canyon
in their names.
As I said before, programming by example isn't a new idea.
What's new in what I've shown you here
is the incorporation of programming
by example into a system that is richly functional as Star,
use of data descriptions to help the user
tell the system what data to use,
and the addition of control structure to a program
by editing a program that's already been recorded.
The goal of this research was to make
programming easier for people who wouldn't normally program.
This goal has been met.
Real Star users have used Small Star,
and have been able to write programs successfully
without much trouble.
Programming by example is a step toward making programming
accessible to everyone.