General Coding Standards › Coding Principles
Coding Principles
- Source code should contain all the information necessary to re-create the object. This should include information about compile time overrides and object attributes.
- Source code should be edited and viewed interactively as much as possible. Source listings should only actually be printed in special circumstances. Use the browsing and scanning facilities of the iSeries to examine source and compilation listings. Adopt layout conventions that facilitate this approach.
- Use the machine to find syntax errors and basic mistakes. The editors and compilers of the iSeries give excellent diagnostics, and can be used to find low-level syntax errors.
- Take an incremental approach to development. OS/400 provides an interactive development environment. Rather than writing and testing programs as entirely separate steps, you can program from top, down. Write the main control structure of a program first, compile and test it, and then add the detailed coding, such as field validation.
- Strictly regulate source versions. One version of the source should be regarded as definitive. If changes are required, additional versions of the source should be copied to a separate development library and only be transferred back, together with the changed object, in a carefully controlled manner. For more information, refer to the section, Operating Environment Standards, in this guide.
- Contain documentation within the source so that it is updated along with the code, and available when looking at the code. The documentation may be extracted and summarized using the CA 2E Toolkit Document Program (YDOCPGM) command.
The CA 2E Toolkit Compile pre-processor utility provides several useful functions common to all source types, including compiler overrides. See the Toolkit Concepts Guide for further details.