Touch Technologies, Inc.
Coding Standards


Previous Contents Index

SHOW_ Prefix

Routines that print information to the screen will carry the "SHOW_" prefix followed by identifying text (for instance, what is printed to the screen).

Example 2-8 SHOW_ Prefix

  Examples:  show_screen 
             show_deal_limit 
             show_oprt_password 

STORE_ Prefix

Routines that store data in a buffer will carry the "STORE_" prefix followed by a description of the data.

Example 2-9 STORE_ Prefix

  Example:  store_audit_info 

INITIALIZE_ Prefix

Routines that initialize will carry the "INITIALIZE_" prefix followed by a description of the data.

Example 2-10 INITIALIZE_ Prefix

  Example:  initialize_data_info 


Chapter 3
Standards for New Programs and Source Code Changes

Overview

Changes made to any source code or new programs will follow the standards explained in Chapters 1 and 2 of this document as well as the following general standards.

3.1 Program Headers

New Programs

Line 1 of all new programs will consist of a correctly formatted header. The header information will include the program name, package name, author, date, work request number and purpose. The following is an example of the correct format:

Example 3-1 Program Header Format

!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! Program:     CF_LIST_DATA 
! System :          
! Author :     John Doe 
! Company:     TTI 
! Date   :     January 11, 2000 
! Purpose:     List data from a file according to the 
!              user's selections. 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

See Section 5.1, GOLD/P Program Template for instructions on how to automatically create a professional program template using a specially mapped keystroke in SPDEV.

If the new program is a modified version of an existing program, the new program will be modified to contain the correct header.

Modified Programs

All programs that are modified will contain documentation of the modification in line 1. This will include the author, date, work request number and purpose. Initials may be eliminated from each line of modified code in cases of extensive modifications. This can be done as long as there is a narrative description in the modification history.

The following is an example of modification documentation:

Example 3-2 Modification Documentation

!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! Program:     CF_LIST_DATA 
! System :          
! Author :     John Doe 
! Company:     TTI 
! Date   :     January 11, 2000 
! Purpose:     List data from a file according to the 
!              user's selections. 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! Modification History 
! Author :     Jane Doe 
! Date   :     January 17, 2000 
! Purpose:     Change list format to fit on standard 
!              8 1/2 by 11 forms. 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
! Modification History 
! Author :     John Doe 
! Date   :     January 27, 2000 
! Purpose:     Add a user selection to print to slave 
!              printer. 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

3.2 Comments

New Programs

Routine headers and comments will be implemented as explained in Chapters 1 and 2 of this document.

If the new program is a modified version of an existing program, any changed or added code must follow the standards. Code not touched does not need to be standardized unless the author wishes to do so.

Modified Programs

Added routines will contain the correct header information and comments as explained in Chapters 1 and 2 of this document.

Lines of code that are changed or added shall be in lower case and commented. The comments will contain the author's initials, work request number and explanation of the change. At least one blank line should separate added code from existing code. The following is an example of changed or added code:

Example 3-3 Changed or Added Code

  print "STARTING PROGRAM AT"; time$ 
 
  call print_a_list 
  !++ call program to print the list to hardcopy 
  !++ jd  wr# IBS-8703102 
 
  print "PROGRAM FINISHED AT"; time$ 

If comments are made as a block comment, programmer initials do not have to be on each line of comments.

3.3 Copied Code

If portions of old code are copied for use in a program, it is considered "fast typing" and the copied code must be brought to standards.

3.4 Error Handling Routines

The major to minor rule for subroutines may not be violated. Error routines should perform minimal processing. Subroutine calls should not be embedded within the error handling routine. See Chapter 1 for a full explanation of major and minor routines.

When it is necessary to print an error message, as much information as possible should be displayed to help the user determine why the error occurred. In the following example, the error message contains the name of the product that was not found:

Example 3-4 Error Messages

!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
routine get_product 
  set structure s1, field product: key product$ 
  if  _extracted = 0  then 
    message error: 'Product ' + product$ + ' not found' 
  end if 
end routine 

3.5 Important Constants

A number that is critical to the operation of the program is known as an "important constant." An example might be .005 which is used in rounding. These numbers must be stored into a variable at the beginning of the program. The variable must then be used for all subsequent code references. For example:

Example 3-5 Storing Critical Numbers into Variables

  round_amount = .005 

If the number needs to be changed at any time, it is easily found and changed in one place without having to search through the program looking for all occurrences.


Chapter 4
Channel Numbers

Overview

When an operation is performed on data files, such as open, print, close, etc., the channel numbers must be variables that distinguish which file is being used. This will help to follow the flow of the program. The user is able to see exactly which file is being processed when reading through the source code.

4.1 Using Channel Variable Names

The channel variables are then used in the source code when an operation is performed on a file. Here is an example:

Example 4-1 Using Channel Variable Names

  open  file report_ch : name 'sheerpower:report.txt', access output 


Chapter 5
Keystrokes for Professional Software Development

Overview

In SheerPower Rapid Development Environment (SPDEV), the following keystrokes have been specially mapped to assist programmers to quickly and easily create professional-looking code:

Table 5-1 SPDEV Programming Keystrokes
  Keystroke Function Performed
  gold/p create program template
  gold/r create routine template
  gold/r create subroutine from routine
  gold/a align equal signs
  gold/c generate debug comment line of !++ xxx date
  gold/d document routine variables in header
  gold/f fixup right margin (fill/wrap)
  gold forward slash comment or uncomment line or block of code
  gold down|up arrow change all unquoted text/code to be upper or lower case
  tab indent selected text/code 2 spaces
  shift+tab move indentation back 2 spaces on selected text/code

The GOLD Key referred to in this section is a special key used to create many of the specialized keystrokes within SPDEV. Both the [Esc] (escape key--top left corner of the keyboard) and the [Num-Lock] (numbers lock key in the numeric keypad) are GOLD keys in SPDEV.

To use the GOLD key, press either GOLD key ([Esc] or [Num-Lock]), let go, then continue with the rest of the keystroke to complete the function.

For a complete listing of specially mapped programming keystrokes in SPDEV, see the SheerPower 4GL - A Guide to the SheerPower Language , Appendix F, Keystrokes for SheerPower Rapid Development Environment.

See Appendix H, SPDEV Menu Item Descriptions (under the "Keystroke Function Mappings Option" heading) for details on how to customize your keymap when using SPDEV.


Previous Next Contents Index