Model 204 naming conventions: Difference between revisions
(6 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
Establishing naming conventions at your site helps everyone involved in reading, writing, or updating Model 204 code. Using consistent naming conventions makes the code easier for future developers to understand. | Establishing naming conventions at your site helps everyone involved in reading, writing, or updating Model 204 code. Using consistent naming conventions makes the code easier for future developers to understand. | ||
==Model 204 | ==Model 204 file names== | ||
<p>The Model 204 restrictions are as follows: </p> | <p>The Model 204 restrictions are as follows: </p> | ||
<ul> | <ul> | ||
<li> | <li>File names are limited to 8 characters (7 for DOS systems).</li> | ||
<li>File names cannot be <var>FILE</var> or <var>GROUP</var>.</li> | |||
<li>File names can contain uppercase letters, numeric digits, or the characters @, #, or $. (The character $ is displayed differently in some countries, often as £). </li> | |||
<li>Filenames cannot begin with a number, nor with any of the following: | |||
<p class="code">CCA (except for [[System requirements for Application Subsystems#Creating CCASYS|CCASYS]]) | |||
SYS | |||
OUT | |||
TAPE </p> | |||
</li> | </li> | ||
<li>Filenames can either describe the file content or conform to local file-naming standards. For example: | |||
<p class="code">EMPLOYE | |||
PER0001 </p> | |||
<li> | |||
Filenames can either describe the file content or conform to local file-naming standards. For example: | |||
<p>EMPLOYE | |||
</ul> | </ul> | ||
<p>It is recommended that you adopt a file-naming standard for your site. This standard should reflect data about the file contents, such as the file number or file description, and link to specific entries in the DICTIONARY. For example: </p> | <p> | ||
It is recommended that you adopt a file-naming standard for your site. This standard should reflect data about the file contents, such as the file number or file description, and link to specific entries in the DICTIONARY. For example: </p> | |||
<table class="noBorder"> | <table class="noBorder"> | ||
<tr><td><b>Application ID:</b></td> <td>PER</td> </tr> | <tr><td><b>Application ID:</b></td> <td>PER</td> </tr> | ||
Line 33: | Line 28: | ||
<p>Model 204 files made up of multiple data sets or that are part of a group should follow a consistent naming scheme. For example: </p> | <p>Model 204 files made up of multiple data sets or that are part of a group should follow a consistent naming scheme. For example: </p> | ||
<p class="code"> | <p class="code">CREATE FILE EMPLOYE FROM EMP000l, EMP0002 ... | ||
CREATE FILE EMPLOYE FROM EMP000l, EMP0002 ... | |||
CREATE PERM GROUP ACCT FROM ACTPROC, ACTDATA | CREATE PERM GROUP ACCT FROM ACTPROC, ACTDATA | ||
</p> | </p> | ||
==Data set names== | ==Data set names== | ||
<p> | |||
<p>Follow these rules when naming the physical data set, as it is known to the operating system: </p> | Follow these rules when naming the physical data set, as it is known to the operating system: </p> | ||
<ul> | <ul> | ||
Line 46: | Line 40: | ||
</li> | </li> | ||
<li>Use a name that incorporates the Model 204 | <li>Use a name that incorporates the Model 204 file name. | ||
</li> | </li> | ||
Line 55: | Line 49: | ||
</li> | </li> | ||
<li>To ease conversion from test to production systems, use the same Model 204 | <li>To ease conversion from test to production systems, use the same Model 204 file name in all Model 204 copies at your site (for example, between test and production copies). This also simplifies file maintenance. | ||
</li> | </li> | ||
Line 65: | Line 59: | ||
<table> | <table> | ||
<tr> | <tr class="head"> | ||
<th>Department </th> | <th>Department </th> | ||
Line 87: | Line 81: | ||
<table> | <table> | ||
<tr> | <tr class="head"> | ||
<th>M204 | <th>M204 file name </th> | ||
<th>Type </th> | <th>Type </th> | ||
<th>Data | <th>Data set name </th> | ||
</tr> | </tr> | ||
Line 137: | Line 131: | ||
==Procedure names== | ==Procedure names== | ||
<p> | |||
<p><var>[[Procedures|Procedure]]</var> names can describe the business function that they support, such as ADDPART or CHGPART, or the names can meet standards already in place, such as XG2104 or BA101A77. </p> | <var>[[Procedures|Procedure]]</var> names can describe the business function that they support, such as <code>ADDPART</code> or <code>CHGPART</code>, or the names can meet standards already in place, such as <code>XG2104</code> or <code>BA101A77</code>. </p> | ||
<p>Document all procedure names in the DICTIONARY with appropriate entries. </p> | <p>Document all procedure names in the DICTIONARY with appropriate entries. </p> | ||
Line 166: | Line 160: | ||
</table> | </table> | ||
== | ==Field names== | ||
<p>Limit the length of <var>[[ | <p> | ||
Limit the length of <var>[[Field names|field names]]</var> to 20 characters. This is long enough to allow a meaningful name, but not so long as to be unwieldy. An advantage to having a formal field name length limit is to simplify passing field names in %variables where you must declare the length of passed arguments. If a field name never exceeds 20 characters, you can safely set the %variable length to 20 and not worry about truncating the field name. </p> | |||
<p>The recommended characters for | <p>The recommended characters for field names are A-Z, 0-9, period (<tt>.</tt>), and underscore (<tt>_</tt>). Using any other special characters, especially spaces, makes the field name more difficult to read and isolate within a program. </p> | ||
<p>When possible, call the same field by the same name if it exists in more than one file, especially if the files are likely to be grouped and used as a logical unit. </p> | <p>When possible, call the same field by the same name if it exists in more than one file, especially if the files are likely to be grouped and used as a logical unit. </p> | ||
===Reserved words=== | ===Reserved words=== | ||
<p>Never use reserved words in | <p> | ||
Never use reserved words in field names. The reserved words in Model 204 are listed in the following table. | |||
</p> | </p> | ||
<table> | <table> | ||
<tr> | <tr class="head"> | ||
<th colspan="4">Model 204 | <th colspan="4">Model 204 reserved words </th> | ||
</tr> | </tr> | ||
Line 188: | Line 184: | ||
<td>OR </td> | <td>OR </td> | ||
<td>EQ </td> | <td>EQ </td> | ||
</tr> | </tr> | ||
Line 198: | Line 194: | ||
<td>RECORD </td> | <td>RECORD </td> | ||
<td>GE </td> | <td>GE </td> | ||
</tr> | </tr> | ||
Line 208: | Line 204: | ||
<td>RECORDS </td> | <td>RECORDS </td> | ||
<td>GT </td> | <td>GT </td> | ||
</tr> | </tr> | ||
Line 218: | Line 214: | ||
<td>TAB </td> | <td>TAB </td> | ||
<td>LE </td> | <td>LE </td> | ||
</tr> | </tr> | ||
Line 228: | Line 224: | ||
<td>THEN </td> | <td>THEN </td> | ||
<td>LT </td> | <td>LT </td> | ||
</tr> | </tr> | ||
Line 238: | Line 234: | ||
<td>TO </td> | <td>TO </td> | ||
<td>NE </td> | <td>NE </td> | ||
</tr> | </tr> | ||
Line 248: | Line 244: | ||
<td>VALUE </td> | <td>VALUE </td> | ||
< | <Td/> | ||
</tr> | </tr> | ||
Line 258: | Line 254: | ||
<td>WHERE </td> | <td>WHERE </td> | ||
< | <Td/> | ||
</tr> | </tr> | ||
Line 268: | Line 264: | ||
<td>WITH </td> | <td>WITH </td> | ||
< | <Td/> | ||
</tr> | </tr> | ||
</table> | </table> | ||
==%Variables== | ==%Variables== | ||
<p> | |||
Keep %variable names under 20 characters and make them understandable to other users. For example: </p> | |||
<p class="code">%DATE = $DATE | |||
<p class=" | |||
%ACCT = Account number | %ACCT = Account number | ||
%CLIENT.ID = Client ID number | %CLIENT.ID = Client ID number | ||
</p> | </p> | ||
<p>When creating %variables to hold the values of global variables, use a G. prefix followed by the name of the global variable. For example: </p> | <p>When creating %variables to hold the values of global variables, use a <code>G.</code> prefix followed by the name of the global variable. For example: </p> | ||
<p class=" | <p class="code">%G.CTL = $GETG('CTL') | ||
%G.CTL = $GETG('CTL') | |||
</p> | </p> | ||
<p>Separate long or | <p>Separate long or multi-part names with periods. For example: </p> | ||
<table> | <table> | ||
<tr> | <tr class="head"> | ||
<th>Data </th> | <th>Data </th> | ||
<th> | <th>Field name </th> | ||
<th>%Variable </th> | <th>%Variable </th> | ||
Line 316: | Line 311: | ||
==Statement labels== | ==Statement labels== | ||
<p>Limit statement labels to | <p> | ||
Limit [[Request composition rules#Statement labels|statement labels]] to twenty characters, and use them wisely. Use statement labels rather than line numbers in new applications. </p> | |||
<p>However, do not try to modify a numbered application to include a mixture of statement numbers and statement labels. If you mix statement labels and statement numbers, or incorrectly modify an application, you might cause Model 204 to branch incorrectly. </p> | <p>However, do not try to modify a numbered application to include a mixture of statement numbers and statement labels. If you mix statement labels and statement numbers, or incorrectly modify an application, you might cause Model 204 to branch incorrectly. </p> | ||
<p>To restrict the use of statement numbers at your site, set <var>[[ | <p>To restrict the use of statement numbers at your site, set <var>[[FOPT parameter|FOPT]]</var> to X’80'. </p> | ||
<p>Statement labels must: </p> | <p>Statement labels must: </p> | ||
<ul> | <ul> | ||
<li> | <li>Start with an alphabetic character (A-Z) </li> | ||
</li> | |||
<li> | <li>Contain only A-Z, 0-9, period (<tt>.</tt>), or underscore (<tt>_</tt>) </li> | ||
</li> | |||
<li> | <li>End with a colon and space (<tt>: </tt>) </li> | ||
</li> | |||
</ul> | </ul> | ||
Line 348: | Line 338: | ||
</p> | </p> | ||
<p>Use consistent names throughout a procedure, with standard prefixes for all applications such as FD. for | <p>Use consistent names throughout a procedure, with standard prefixes for all applications such as <code>FD.</code> for <var>Find</var> statements, <code>CT.</code> for <var>Count</var> statements, and so on. For example: </p> | ||
<table> | <table> | ||
<tr class="head"><th>Label</th><th>Statement</th></tr> | |||
<tr> | <tr> | ||
<td>FD.WELL.NAME: </td> <td>FIND RECORDS </td> | <td>FD.WELL.NAME: </td> <td>FIND RECORDS </td> | ||
Line 372: | Line 364: | ||
<ul> | <ul> | ||
<li> | <li> | ||
A statement that is referred to by another statement within a procedure, as in a COUNT RECORDS IN label statement. | A statement that is referred to by another statement within a procedure, as in a <var>COUNT RECORDS IN <i>label</i></var> statement. | ||
</li> | </li> | ||
<li> | <li> | ||
A statement that follows a FIND or STORE statement and does not have an END statement. However, the coding of an END statement is | A statement that follows a <var>FIND</var> or <var>STORE</var> statement and does not have an <var>END</var> statement. However, the coding of an <var>END</var> statement is preferable in this situation. | ||
</li> | </li> | ||
</ul> | </ul> | ||
Line 383: | Line 375: | ||
<ul> | <ul> | ||
<li>FIND statements (except FIND ALL VALUES) | <li><var>FIND</var> statements (except <var>FIND ALL VALUES</var>) </li> | ||
</li> | |||
<li>FOR loops | <li><var>FOR</var> loops </li> | ||
</li> | |||
<li>STORE | <li><var>STORE</var> </li> | ||
</li> | |||
<li>ON | <li><var>ON</var> </li> | ||
</li> | |||
<li>Subroutines | <li>Subroutines </li> | ||
</li> | |||
</ul> | </ul> | ||
==Subroutines== | ==Subroutines== | ||
<p>Begin subroutine labels with the prefix SUB or with the first three characters of the subroutine name. Once your site picks a style, be consistent. </p> | <p>Begin subroutine labels with the prefix <code>SUB</code> or with the first three characters of the subroutine name. Once your site picks a style, be consistent. </p> | ||
===Simple subroutines=== | ===Simple subroutines=== | ||
<p>Begin the names of %variables unique to a subroutine with a %SUB prefix, or with the first three characters of the subroutine name. For example: </p> | <p>Begin the names of %variables unique to a subroutine with a <code>%SUB</code> prefix, or with the first three characters of the subroutine name. For example: </p> | ||
<p class="code">%SUB.WELL.DATE | <p class="code">%SUB.WELL.DATE | ||
Line 411: | Line 398: | ||
===Complex subroutines=== | ===Complex subroutines=== | ||
<p>To avoid conflicts in subroutine names, prefix all subroutines that reside in a procedure file outside your current file with a name unique to the procedure file. For example, if you have a procedure file containing various subroutines used for printing out data and named PRTSUBS: </p> | <p>To avoid conflicts in subroutine names, prefix all subroutines that reside in a procedure file outside your current file with a name unique to the procedure file. For example, if you have a procedure file containing various subroutines used for printing out data and named <code>PRTSUBS</code>: </p> | ||
<p class="code">PRTSUBS.SALES | <p class="code">PRTSUBS.SALES | ||
Line 417: | Line 404: | ||
</p> | </p> | ||
<p>Distinguish between internal and external subroutines. Use, for example, an IN and an EX prefix to differentiate between the two: </p> | <p>Distinguish between internal and external subroutines. Use, for example, an <code>IN</code> and an <code>EX</code> prefix to differentiate between the two: </p> | ||
<p class="code">IN.WELL.DATE | <p class="code">IN.WELL.DATE | ||
Line 425: | Line 412: | ||
==Other naming convention considerations== | ==Other naming convention considerations== | ||
<p>Make screen, menu, and report names reflect the business function performed. For example, you might want to name a menu used to add employee information EMP.INFO.MENU or a quarterly sales report QTR.SALES.RPT. </p> | <p>Make screen, menu, and report names reflect the business function performed. For example, you might want to name a menu used to add employee information <code>EMP.INFO.MENU</code>, or name a quarterly sales report <code>QTR.SALES.RPT</code>. </p> | ||
<p>When using a record type field to distinguish between different record types within the same file, abbreviate the rectype name, but keep it meaningful and descriptive of the record's content. This helps make the data self-descriptive. </p> | <p>When using a record type field to distinguish between different record types within the same file, abbreviate the rectype name, but keep it meaningful and descriptive of the record's content. This helps make the data self-descriptive. </p> | ||
<p>For example, in the Model 204 demonstration database, there are two types of records in the CLIENTS file. They are RECTYPE = POLICYHOLDER, for the records containing information about the holder of the insurance policy, and RECTYPE = DRIVER for records about every driver listed on any insurance policy. </p> | <p>For example, in the Model 204 demonstration database, there are two types of records in the CLIENTS file. They are <code>RECTYPE = POLICYHOLDER</code>, for the records containing information about the holder of the insurance policy, and <code>RECTYPE = DRIVER</code> for records about every driver listed on any insurance policy. </p> | ||
[[Category: Application development]] | [[Category: Application development]] | ||
[[Category: Overviews]] | [[Category: Overviews]] |
Latest revision as of 20:35, 26 September 2016
Introduction
Establishing naming conventions at your site helps everyone involved in reading, writing, or updating Model 204 code. Using consistent naming conventions makes the code easier for future developers to understand.
Model 204 file names
The Model 204 restrictions are as follows:
- File names are limited to 8 characters (7 for DOS systems).
- File names cannot be FILE or GROUP.
- File names can contain uppercase letters, numeric digits, or the characters @, #, or $. (The character $ is displayed differently in some countries, often as £).
- Filenames cannot begin with a number, nor with any of the following:
CCA (except for CCASYS) SYS OUT TAPE
- Filenames can either describe the file content or conform to local file-naming standards. For example:
EMPLOYE PER0001
It is recommended that you adopt a file-naming standard for your site. This standard should reflect data about the file contents, such as the file number or file description, and link to specific entries in the DICTIONARY. For example:
Application ID: | PER |
Numeric File ID: | 0001 |
File Description: | Personnel Data |
DDNAME/Model 204 Name: | PER0001 |
Model 204 files made up of multiple data sets or that are part of a group should follow a consistent naming scheme. For example:
CREATE FILE EMPLOYE FROM EMP000l, EMP0002 ... CREATE PERM GROUP ACCT FROM ACTPROC, ACTDATA
Data set names
Follow these rules when naming the physical data set, as it is known to the operating system:
- Use an identifier to indicate that the file is a Model 204 file. Distinguish between live and dump files.
- Use a name that incorporates the Model 204 file name.
- Where applicable, use a name that contains an application or data identifier.
- Use a name that identifies whether the file is a test or a production file.
- To ease conversion from test to production systems, use the same Model 204 file name in all Model 204 copies at your site (for example, between test and production copies). This also simplifies file maintenance.
- If your site has both data and procedure files, clearly distinguish between the two.
For example, if your site uses these identifiers:
Department | System within the Department |
---|---|
PER Personnel | BEN Benefits |
ACT Accounting | GL General Ledger |
You then set up your file system based on the identifiers:
M204 file name | Type | Data set name |
---|---|---|
BEN0001 | Live file (Test) | PER.TEST.BEN0001.M204 |
GL00011 | Live file | ACT.PROD.GL00011.M204 |
BENDMP1 | Dump file | PER.PROD.BEN0001.DUMP |
BENPRC1 | Proc file | PER.PROD.BENPRC1.M204 |
GLPRC3 | Proc file | ACT.PROD.GLPRC3.M204 |
Procedure names
Procedure names can describe the business function that they support, such as ADDPART
or CHGPART
, or the names can meet standards already in place, such as XG2104
or BA101A77
.
Document all procedure names in the DICTIONARY with appropriate entries.
If multiple subsystems share the same procedure file, use the subsystem name as part of the prefix to distinguish among procedures from different subsystems.
When using the application subsystem facility, you must use a prefix to distinguish between precompiled and nonprecompiled procedures. It is recommended that something, such as using P. and N. prefixes, is used for precompiled and nonprecompiled procedures. For example:
P.DAILYAVG | N.TABLESRT |
P.DEL.REC | N.OPEN.PROC |
P.ADD.STORE | N.PER.SETUP |
Field names
Limit the length of field names to 20 characters. This is long enough to allow a meaningful name, but not so long as to be unwieldy. An advantage to having a formal field name length limit is to simplify passing field names in %variables where you must declare the length of passed arguments. If a field name never exceeds 20 characters, you can safely set the %variable length to 20 and not worry about truncating the field name.
The recommended characters for field names are A-Z, 0-9, period (.), and underscore (_). Using any other special characters, especially spaces, makes the field name more difficult to read and isolate within a program.
When possible, call the same field by the same name if it exists in more than one file, especially if the files are likely to be grouped and used as a logical unit.
Reserved words
Never use reserved words in field names. The reserved words in Model 204 are listed in the following table.
Model 204 reserved words | |||
---|---|---|---|
AFTER | END | OR | EQ |
ALL | FROM | RECORD | GE |
AND | IN | RECORDS | GT |
AT | IS | TAB | LE |
BEFORE | LIKE | THEN | LT |
BY | NOR | TO | NE |
COUNT | NOT | VALUE | |
EACH | OCC | WHERE | |
EDIT | OCCURRENCE | WITH |
%Variables
Keep %variable names under 20 characters and make them understandable to other users. For example:
%DATE = $DATE %ACCT = Account number %CLIENT.ID = Client ID number
When creating %variables to hold the values of global variables, use a G.
prefix followed by the name of the global variable. For example:
%G.CTL = $GETG('CTL')
Separate long or multi-part names with periods. For example:
Data | Field name | %Variable |
---|---|---|
Client number | CLIENT.NO | %CLIENT.NO |
Client address | CLIENT.ADDR | %CLIENT.ADDR |
Statement labels
Limit statement labels to twenty characters, and use them wisely. Use statement labels rather than line numbers in new applications.
However, do not try to modify a numbered application to include a mixture of statement numbers and statement labels. If you mix statement labels and statement numbers, or incorrectly modify an application, you might cause Model 204 to branch incorrectly.
To restrict the use of statement numbers at your site, set FOPT to X’80'.
Statement labels must:
- Start with an alphabetic character (A-Z)
- Contain only A-Z, 0-9, period (.), or underscore (_)
- End with a colon and space (: )
For example:
FD.MARKETS: FIND ALL RECORDS FOR WHICH... CT.COMP.REC: COUNT RECORDS IN FD.COMP.REC... DATE_MATCH: FIND ALL RECORDS...
Use consistent names throughout a procedure, with standard prefixes for all applications such as FD.
for Find statements, CT.
for Count statements, and so on. For example:
Label | Statement |
---|---|
FD.WELL.NAME: | FIND RECORDS |
CT.WELL.NAME: | COUNT RECORDS |
SRT.WELL.NAME: | SORT RECORDS |
FDR.WELL.NAME: | FIND AND RESERVE RECORDS |
Statement labels are required under the following conditions:
- A statement that is referred to by another statement within a procedure, as in a COUNT RECORDS IN label statement.
- A statement that follows a FIND or STORE statement and does not have an END statement. However, the coding of an END statement is preferable in this situation.
Although not required, statement labels might be useful in the following cases:
- FIND statements (except FIND ALL VALUES)
- FOR loops
- STORE
- ON
- Subroutines
Subroutines
Begin subroutine labels with the prefix SUB
or with the first three characters of the subroutine name. Once your site picks a style, be consistent.
Simple subroutines
Begin the names of %variables unique to a subroutine with a %SUB
prefix, or with the first three characters of the subroutine name. For example:
%SUB.WELL.DATE %WEL.DATE
Complex subroutines
To avoid conflicts in subroutine names, prefix all subroutines that reside in a procedure file outside your current file with a name unique to the procedure file. For example, if you have a procedure file containing various subroutines used for printing out data and named PRTSUBS
:
PRTSUBS.SALES PRTSUBS.REGION
Distinguish between internal and external subroutines. Use, for example, an IN
and an EX
prefix to differentiate between the two:
IN.WELL.DATE EX.PRT.RECS
Other naming convention considerations
Make screen, menu, and report names reflect the business function performed. For example, you might want to name a menu used to add employee information EMP.INFO.MENU
, or name a quarterly sales report QTR.SALES.RPT
.
When using a record type field to distinguish between different record types within the same file, abbreviate the rectype name, but keep it meaningful and descriptive of the record's content. This helps make the data self-descriptive.
For example, in the Model 204 demonstration database, there are two types of records in the CLIENTS file. They are RECTYPE = POLICYHOLDER
, for the records containing information about the holder of the insurance policy, and RECTYPE = DRIVER
for records about every driver listed on any insurance policy.