All this work with damsels and trains is making Eunice feel a bit run down, so she decides to stop working on her characters for a little while, and to work a bit on the main plot.
Accordingly, she sets her pen to the sheet of paper labeled main routine.
Here is the main plot of the Gunfight at the Old West Saloon: There is a Western Town called Sweaty Post. Sweaty Post has two saloons, one sheriff, and five troublemakers. There is a male villain named Maurice. Maurice has a black hat, a red mustache, and a horse named "Beer Gut". Maurice prefers Jack Daniels whiskey. Mary is a female human. She has a horse named "Midnight" and she prefers her whiskey straight. In our story, Maurice starts out by drinking whiskey. He then lets everyone know how drunk he is, and then ties up a woman named Mary. |
Here is the main plot of Gunfight at the Old West Saloon;
|
public class Gunfight {
public static void main(String arguments[]) {
} |
So what is so special about this plot? Well, it's not everything that's happening in the main routine, but rather everything that happens behind the scenes. When Eunice created that town called Sweaty Post, she created (instantiated) an object of type Western Town. This object had all the characteristics of a standard Western Town (do you remember the binders?) The same thing goes for the Maurice object and the (pardon me for this) Mary object. While some of the traits of these objects were specified at the time of creation, most of their traits were specified back in the binders, or classes. This allowed Eunice to say a good deal while only saying a little bit in her main routine.
So Eunice's main plot (routine) turns out to be nothing more than a collection of references to objects, which in turn are references to classes. It is, to mix metaphors again, literary federalism, with everything being dealt with at the lowest level possible.
So what are the benefits of this? Well, imagine that instead of one page, Eunice's editor wanted a book of five hundred pages. Or let's say that Eunice decided that Maurice the villain shouldn't be so cruel. Instead of going back and laboriously changing all her instances of Maurice eating kittens and tripping old people (or whatever it is that bad folks do), Eunice could just make some changes to the Maurice object at the time of instantiation. Or she could change the Villain class to be friendlier. Or she could even create a *new* class, called FriendlyVillain with some aspects of the Samuel L. Jackson character in Pulp Fiction. She's got a lot of options; the point is that she only needs to make the changes in one place.
But that's not Eunice's only reason for writing her books in Java. She has a keen idea for the future of Westerns. She sees interactivity. And if, instead of being bound in pages, her characters live in objects and classes, Eunice is free to create a Virtual Sweaty Post. Readers (on her website) could be prompted for their own actions and her characters could respond in a variety of ways, according to what was written in their classes. Using Java, Eunice could finally bring the Old West back to life. And hey, I'm sure she's not the only one yearning for the days of outhouses, blood, and dust.
![]() |
![]() |
![]() |