Editing
Naming and Coding Standards
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== 4. Data Naming Conventions == <span id="general-rules"></span> === 4.1 General rules === {| !width="50%"| Rule !width="50%"| Rationale |- | Use hyphens as word separators: <code>test-number</code>, not <code>testNumber</code> or <code>test_number</code> | COBOL convention; underscores are non-standard in some compilers |- | Maximum name length: 30 characters (COBOL 85 limit) | Portability |- | Names must be meaningful: no single-letter names except loop indexes | Readability |- | Avoid COBOL reserved words and common abbreviations that conflict (e.g. <code>LENGTH</code>, <code>SPACE</code>) | Prevents ambiguity |- | Prefix 88-level condition names with the purpose they test, not the field name | <code>dal-method-ok</code> not <code>dal-result-zero</code> |} <span id="level-number-conventions"></span> === 4.2 Level number conventions === {| !width="50%"| Level !width="50%"| Use |- | 01 | Group items, independent items, copybook roots |- | 03, 05, 07 | Subordinate group and elementary items (use odd numbers: 01, 03, 05, 07 …) |- | 66 | RENAMES clause (use sparingly) |- | 77 | Independent elementary items (prefer 01 unless 77 is clearly appropriate) |- | 88 | Condition names; always immediately under the field they qualify |} '''Rule:''' Use odd-numbered levels (01, 03, 05, 07, 09) to allow insertion of intermediate levels without renumbering. Never use even levels in new code. <span id="naming-prefixes-for-scope"></span> === 4.3 Naming prefixes for scope === {| !width="33%"| Prefix !width="33%"| Meaning !width="33%"| Example |- | <code>r-</code> | Record / row field (fetched from DB) | <code>r-ident</code>, <code>r-prime</code> |- | <code>u-</code> | UI-layer field (in primes-ui block) | <code>u-sequence</code>, <code>u-number</code> |- | <code>t-</code> | Table cell / temporary print field | <code>t-ident</code>, <code>t-prime</code> |- | <code>f-</code> | Formatted / print-ready field | <code>f-page-number</code> |- | <code>w-</code> | Work field (local computation) | <code>w-remainder</code> |} <span id="picture-clause-conventions"></span> === 4.4 Picture clause conventions === {| !width="33%"| Type !width="33%"| Preferred PICTURE !width="33%"| Notes |- | Positive integer, display | <code>9(n)</code> | n ≤ 9 for standard arithmetic |- | Signed integer, display | <code>S9(n)</code> | Use S prefix for fields that can go negative or are SQL host variables |- | Packed decimal | <code>S9(n) COMP-3</code> | For high-volume arithmetic and SQL host variables |- | Binary integer | <code>S9(n) COMP-5</code> | For SQLCA fields and counters needing maximum performance |- | Fixed decimal | <code>9(n)V9(m)</code> | V = implied decimal point; no actual decimal character stored |- | Alphanumeric | <code>X(n)</code> | For text, method verbs, messages |- | Edited numeric (print) | <code>Z(n)9</code> or <code>Z(n)</code> | For zero-suppressed print output only; never used in arithmetic |- | Boolean flag | <code>9(1)</code> with 88-levels | e.g. <code>PIC 9 VALUE 1. 88 new-page VALUE 1.</code> |} <span id="level-condition-names"></span> === 4.5 88-level condition names === * Must be named for what is '''true''' when the condition fires, not for the value: <code>session-method-ok</code> not <code>result-is-zero</code>. * Result-code 88-levels must cover all meaningful values; add a <code>88 invalid-method VALUE "bad"</code> sentinel. * Multiple conditions for the same field must have non-overlapping VALUES. <span id="copybook-field-naming"></span> === 4.6 Copybook field naming === * Fields in a copybook must be globally unique across all copybooks in the project (COBOL does not namespace copybooks). * Prefix copybook fields with the copybook’s logical name: <code>dal-methods</code>, <code>ui-method-result</code>, <code>session-result</code>. ----- <span id="paragraph-naming-conventions"></span>
Summary:
Please note that all contributions to Webhuis wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see
Project:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Voorpagina
Cobol and PostgreSQL
PostgreSQL
CFEngine
Proxmox
Webhuis Kennisbank
Basale infra
Webhuis bouwstenen
Webhuis configuratie
Webhuis Infra
Webhuis Support
Webhuis Raspberry
Opzet Applicaties
Business Applicaties
Community portal
Current events
Recent changes
Random page
Help
sitesupport
Tools
What links here
Related changes
Special pages
Page information