151x Filetype PDF File size 0.25 MB Source: cse.buffalo.edu
General Coding Standards DATE POLICY # REV PAGE # 2/19/03 1 1 General Style and Coding Standards for Software Projects Preliminary Version AUTHOR(s): APPROVED: Revised: Standards Group SEPG General Coding Standards DATE POLICY # REV PAGE # 2/19/03 1 2 Table Of Contents 1. INTRODUCTION 1.1 PURPOSE 5 1.2 Scope 6 1.3 Coding Standard Documents: 6 1.4 Other Related Project Documents 6 1.5 Terms Used In This Document 6 1.6 References 7 1.7 Our Limited Lifetime Warranty 7 1.8 The Emotional Topic of Coding Standards 7 2. PROJECT DEPENDENT STANDARDS 7 3. FILE AND MODULE GUIDELINES 8 3.1 Module Design Guidelines 9 3.2 Header (Include) Files 9 3.2.1 Use consistent implementation strategy for header files 9 3.2.2 Header file Guidelines: 9 3.3 Source File Layout Guideline 10 3.4 File Naming Guideline 10 3.5 File and Module Informational Headers 10 3.5.1 File Header 11 3.5.2 Subroutine Header 12 4. CONSTANTS AND MACROS 13 4.1 Use constants and macros instead of hard coded literal values 14 4.2 Only Define constants and macros once 14 4.3 Place parenthesis around each macro parameters 14 4.4 Notes about style 14 5. GLOBAL DATA GUIDELINES: 15 AUTHOR(s): APPROVED: Revised: Standards Group SEPG General Coding Standards DATE POLICY # REV PAGE # 2/19/03 1 3 6. SUBROUTINES 15 6.1 Subroutine Scope Guideline 15 6.2 Subroutine Declaration Guidelines: 15 6.3 Subroutine Layout Guidelines: 15 6.4 Subroutine Size Guideline 15 6.5 Parameter List Guideline 15 6.6 Variable Declaration Guidelines: 16 7. COMMENTS 16 7.1 “Distributed Code Description “ 16 7.2 Comment Block Standard: 16 7.3 In line comments: 17 7.4 Commenting control constructs 17 8. CODE LAYOUT 17 8.1 One statement per line 17 8.2 Indentation Guidelines 18 8.3 Brackets, Begin...End, and Delimiting Control Blocks 18 8.4 Error Handling 20 9. NAMING CONVENTION FOR IDENTIFIERS (VARIABLES, CONSTANTS, AND SUBROUTINES) 20 9.1 Select Clear and Meaningful Names 20 9.2 Naming Subroutines (verb and object) 21 9.3 Naming Constants, variables (noun) 21 9.4 Naming Boolean identifiers (verb and ((object or adjective)) 21 9.5 Naming Types 21 9.6 Use of upper/lower case and underscores to differentiate Subroutines, Variables, and Constants. 22 9.7 Subroutines and Program Units: 22 9.8 Variables 22 AUTHOR(s): APPROVED: Revised: Standards Group SEPG General Coding Standards DATE POLICY # REV PAGE # 2/19/03 1 4 9.9 Macros and Constants 22 9.10 Use of prefix (Hungarian) notations to differentiate the scope and type of a data variable 22 9.10.1 Identifying data types 23 9.11 Abbreviations 25 9.12 Summary table for Naming Convention: 26 10. MISC. RULES FOR CODING 27 10.1 Conditionals and comparisons 27 10.2 Program Flow 27 10.3 Binding time of variables and values 27 10.4 Go-tos, pointers, and issues of clarity 28 10.5 Strive to develop clear code 28 10.6 Use libraries when available 28 10.7 Type casting integer and float variables makes code more portable 28 10.8 Compiler dependent code should include tests 29 10.9 Use ASCII files for runtime or machine dependent constants and macros 29 10.10 Error Handling 29 10.11 Debugging 29 10.12 Using structures and enumerators is recommended 29 11. MODULARIZATION AND INFORMATION HIDING 30 11.1 Information Hiding , domain, and scope of variables 30 11.2 Low Coupling , High Cohesion, and Clean interfaces 30 11.3 Cohesion 30 11.4 Coupling 30 11.5 Clean Interface 30 11.6 Minimize scope of variables 31 AUTHOR(s): APPROVED: Revised: Standards Group SEPG
no reviews yet
Please Login to review.