0% found this document useful (0 votes)
713 views

Coding Standard Template

This document provides guidelines for coding standards, including: - Sections on counting lines of code, writing descriptive program headers, commenting code, using descriptive identifiers, and formatting with spacing and indentation. - Examples are provided for headers, contents, code reuse instructions, comments, major sections, indenting, and capitalization. - The purpose is to guide development of programs and documentation to ensure consistency and readability.

Uploaded by

Tatiana Ramos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
713 views

Coding Standard Template

This document provides guidelines for coding standards, including: - Sections on counting lines of code, writing descriptive program headers, commenting code, using descriptive identifiers, and formatting with spacing and indentation. - Examples are provided for headers, contents, code reuse instructions, comments, major sections, indenting, and capitalization. - The purpose is to guide development of programs and documentation to ensure consistency and readability.

Uploaded by

Tatiana Ramos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Coding Standard Template

Purpose To guide the development of programs

Counting Standard ● Count each physical line as one LOC.


● Do not count blank lines and comment-only lines.
● Be consistent about what you put on each physical line.
Program Headers Begin all programs with a descriptive header.
Header Format

Contents Provide a summary of the contents.


Contents
Example

Reuse Instructions ● Describe how the program is used. Provide the declaration format,
parameter values and types, and parameter limits.
● Provide warnings of illegal values, overflow conditions, or other conditions
that could potentially result in improper operation.
Reuse Example

Identifiers Use descriptive names for all variables, function names, constants, and other

Coding Standard Template June 2010  2010 by Carnegie Mellon University


identifiers. Avoid abbreviations or single letter variables.
Identifier Example

(continued)

Coding Standard Template June 2010  2010 by Carnegie Mellon University


Coding Standard Template (continued)

Comments ● Document the code so that the reader can understand its operation.
● Comments should explain both the purpose and behavior of the code.
● Comment variable declarations to indicate their purpose.
Good Comment

Bad Comment

Major Sections Precede major program sections by a block comment that describes the
processing that is done in the next section
Example

Blank Spaces ● Write programs with sufficient spacing so they do not appear crowded.
● Separate every program construct with at least one space.
Indenting ● Indent every level of brace from the previous one.
● Open and closing braces should be on lines by themselves and aligned with
each other.
Indenting
Example

Capitalization ● Capitalized all defines.


● Lowercase all other identifiers and reserved words.
● Messages being output to the user can be mixed-case so as to make a clean
user presentation.
Capitalization
Example

Coding Standard Template June 2010  2010 by Carnegie Mellon University

You might also like