Java Technology
Class Coding Template

Overview

This template is intended to assist in the creation of a Java class. It is based on the assumption that deletion of extraneous information is easier than remembering or looking up a seldom-used construct. Thus, the template lists all syntactical constructs valid for a class declaration (except inner classes), including valid javadoc comment tags. Descriptions of most constructs in the template may be found in the Class Declaration Syntax Summary.

The template is used by

  1. Copying it into a file with an appropriate name (i.e., the file name should be same as the name of the class, only with ".java" appended);
  2. Using the search-and-replace feature of your editor to replace the string "ClassName" with the name of the class, and the string "package_name" with the name of the package for the class;
  3. Deleting template code that is not needed and/or self-contradictory (for example, a class cannot be both abstract and final, so one of these modifiers must be deleted in your class declaration);
  4. Adding code as necessary to complete the class.

The template layout is designed for maximum readability and maintainabilty, and reflects L's Java coding style. It is expected that individuals will change the layout of the template to suit individual or project coding styles.

The template may be downloaded by using the 'Save' or 'Sava As' option of your browser, and by stripping off the leading and trailing HTML syntax. This template may be freely redistributed and used.

Class Coding Template

/*                      package_name.ClassName
 */
package package_name;

import  external_package.external_class_name;
import  external_package.*;

/*
 * Application: 
 * 
 * Copyright (C) date copyright_holder
 */
/**
 * Class Purpose: 
 * <p>
 * Notes: 
 * <p>
 * @version version_number
 * @author  author_name
 */
public abstract final class ClassName extends superclass
                                   implements interface, interface {

/*
 ******************************************************************************
 *                      Field Variable Declarations
 ******************************************************************************
 *
 *                      Constant Fields
 */
/**
 *                      description
 *                      @serial field_name field_type
 *                      @since  version
 *                      @see    #methodName
 *                      @see    external_classname#methodName
 */
  private static final transient type FIELD_NAME = constant;
  private static final transient type[] FIELD_NAME = {constant, constant};

/*
 *----------------------------------------------------------------------------
 *
 *                      Private Static Fields
 */
/**
 *                      description
 *                      @serial field_name field_type
 *                      @since  version
 *                      @see    #methodName
 *                      @see    external_classname#methodName
 */
  private static transient volatile type field_name = constant;
  private static transient volatile type[] field_name = {constant, constant};

/*
 *----------------------------------------------------------------------------
 *
 *                      Private Instance Fields
 */
/**
 *                      description
 *                      @serial field_name field_type
 *                      @since  version
 *                      @see    #methodName
 *                      @see    external_classname#methodName
 */
  private transient volatile type field_name = constant;
  private transient volatile type[] field_name = {constant, constant};
/*
 ******************************************************************************
 *                      Static Initializers
 ******************************************************************************
 *
 *                      ClassName Static Initializer
 */
  static {
    ClassName.static_field_name = constant;
    statement;
  }
/*
 ******************************************************************************
 *                      Constructor Methods
 ******************************************************************************
 *
 *                      ClassName Constructor #1
 */
/**
 * Purpose:
 * <p>
 * Notes:
 * <p>
 * @param     arg_name description
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected|private ClassName (type arg_name, type arg_name)
  throws exception_name, exception_name {
    super ();
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
  }
/*
 ******************************************************************************
 *
 *                      ClassName Constructor #2
 */
/**
 * Purpose:
 * <p>
 * Notes:
 * <p>
 * @param     arg_name description
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected|private ClassName (type arg_name, type arg_name)
  throws exception_name, exception_name {
    this ();
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
  }
/*
 ******************************************************************************
 *                      Field Accessor and Mutator Methods
 ******************************************************************************
 *
 *                      ClassName.methodName
 */
/**
 * Purpose:
 * <p>
 * Notes:
 * <p>
 * @param     arg_name description
 * @return    description
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected|private static final synchronized native
  type|void methodName (type arg_name, type arg_name)
  throws exception_name, exception_name {
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
    return type;                                 // description
  }
/*
 ******************************************************************************
 *
 *                      ClassName.methodName
 */
/**
 * Purpose:
 * <p>
 * Notes:   
 * <p>
 * @param     arg_name description
 * @return    description
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected|private static final synchronized native
  type|void methodName (type arg_name, type arg_name)
  throws exception_name, exception_name {
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
    return type;                                 // description
  }
/*
 ******************************************************************************
 *                      Object Behavior Methods
 ******************************************************************************
 *
 *                      ClassName.methodName
 */
/**
 * Purpose:
 * <p>
 * Notes:
 * <p>
 * @param     arg_name description
 * @return    description
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected|private static final synchronized native
  type|void methodName (type arg_name, type arg_name)
  throws exception_name, exception_name {
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
    return type;                                 // description
  }
/*
 ******************************************************************************
 *
 *                      ClassName.methodName
 */
/**
 * Purpose:
 * <p>
 * Notes:   
 * <p>
 * @param     arg_name description
 * @return    description
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected|private static final synchronized native
  type|void methodName (type arg_name, type arg_name)
  throws exception_name, exception_name {
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
    return type;                                 // description
  }
/*
 ******************************************************************************
 *                      event Listener Methods
 ******************************************************************************
 *
 *                      ClassName.methodName
 */
/**
 * Purpose:
 * <p>
 * Notes:
 * <p>
 * @param     e The xxx event.
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected|private synchronized void methodName (xxxEvent e)
  throws exception_name, exception_name {
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
    return;                                      // description
  }
/*
 ******************************************************************************
 *
 *                      ClassName.methodName
 */
/**
 * Purpose:
 * <p>
 * Notes:   
 * <p>
 * @param     e The xxx event.
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected|private synchronized void methodName (xxxEvent e)
  throws exception_name, exception_name {
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
    return;                                      // description
  }
/*
 ******************************************************************************
 *                      Response Behavior Methods
 ******************************************************************************
 *
 *                      ClassName.methodName
 */
/**
 * Purpose:
 * <p>
 * Notes:
 * <p>
 * @param     arg_name description
 * @return    description
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected|private static final synchronized native
  type|void methodName (type arg_name, type arg_name)
  throws exception_name, exception_name {
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
    return type;                                 // description
  }
/*
 ******************************************************************************
 *
 *                      ClassName.methodName
 */
/**
 * Purpose:
 * <p>
 * Notes:   
 * <p>
 * @param     arg_name description
 * @return    description
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected|private static final synchronized native
  type|void methodName (type arg_name, type arg_name)
  throws exception_name, exception_name {
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
    return type;                                 // description
  }
/*
 ******************************************************************************
 *                      Abstract Methods
 ******************************************************************************
 *
 *                      ClassName.methodName
 */
/**
 * Purpose:
 * <p>
 * Notes:
 * <p>
 * @param     arg_name description
 * @return    description
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected abstract type|void methodName (type arg_name, type arg_name)
  throws exception_name, exception_name ;
/*
 ******************************************************************************
 *
 *                      ClassName.methodName
 */
/**
 * Purpose:
 * <p>
 * Notes:
 * <p>
 * @param     arg_name description
 * @return    description
 * @exception exception_name description
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public|protected abstract type|void methodName (type arg_name, type arg_name)
  throws exception_name, exception_name ;
/*
 ******************************************************************************
 *                      Application main Method or
 *                      Class Unit Test main Method
 ******************************************************************************
 *
 *                      ClassName.main
 */
/**
 * Purpose:  
 * <p>
 * Notes:
 * <p>
 * @param     args command line arguments.
 * @see       #methodName
 * @see       external_classname#methodName
 */
  public static void main (String[] args) {
                                                 // Local Variables
    type var_name = constant;                    // description
    type[] var_name = {constant, ...};           // description
                                                 // End of Local Variables

    body_statement;                              // description
    return;                                      //
  }
}                       // End of package_name.ClassName


[home]
[OO] [Java] [memorial ships]
[humor] [income tax repeal]


Copyright (C) 1998 LDJ Trust