Computer Science Java Style
Introduction
Fundamental Notions and First Constructs

The Basic Java Application Template

Basic Concepts

A java template is a text containing slots and invariant textual information. A java slot is an easily identified marker which is replaced by a filler in the process of transforming a java template into a java program. A java filler is just the java program fragment which replaces a java slot.

Motivation

The motivation behind the java templates is to ease your burden by eliminating the need to type invariant technical information. This frees you to focus your attention on novel concepts and constructs. By reducing the typing you must do, use of the templates serves to reduce the number of typing errors that you will make, and consequent lexical errors in Java. The basic Java application template is shown below. The current date is automatically entered for you.

The Template


// General Information
// ------------------------------------------------------------

// File:  <?CLASS>.java
// Type:  java application file
// Date:  Sun Oct 15, 1995
// Name:  <?AUTHOR>
// Line:  <?LINE>


// Application Description
// ------------------------------------------------------------

/*

   <?DESCRIPTION>

*/


// Required Packages
// ------------------------------------------------------------

   import blue.io.*;
   <?NEEDS>


// Application Class
// ------------------------------------------------------------

   class <?CLASS>
   {
      static public void main (String args[])
      {
      <?PROGRAM>
      }
   }

// Demo
// ------------------------------------------------------------

/*

   <?DEMO>

*/

Slots and Fillers

The slots of the simple Java application template represent information as indicated below.
  1. <?CLASS> represents the name of the application class being defined.
  2. <?NAME> represents the name of the author of the program.
  3. <?LINE> represents a one line description of the program.
  4. <?DESCRIPTION> represents a multiple line description of the program.
  5. <?NEEDS> represents information describing classes required by the program.
  6. <?PROGRAM> represents a demonstration of the Java program.
  7. <?DEMO> represents a demonstration of the program in action.
The slots are instantiated as follows in the CoffeeApp program.
  1. <?CLASS> --> CoffeeApp
  2. <?NAME> --> BLUE
  3. <?LINE> --> Variation of "Hello world!", the traditional starter.
  4. <?DESCRIPTION> --> Program to display "Coffee is good!" to the standard output file.
  5. <?NEEDS> -->
  6. <?PROGRAM> --> IO.println("Coffee is good!");
  7. <?DEMO> -->
    indigo> javac CoffeeApp.java
    indigo> java CoffeeApp
    Coffee is good.
    indigo>

Pragmatics of Use

You can generate a "Basic Java application template" by issuing the "generate basic Java application template" emacs command. You can move to the next slot by issuing the emacs "jump to next slot" command. You can delete the previous slot by issuing the emacs "Delete Previous Slot" command. The demo will be generated in the context of a "shell". You will replace <?DEMO> with the demo by means of the emacs "transfer demo" command.


Craig Graci
Last modified: Tue Jan 21 12:58:43 EST