coding standards
 
home | 163 | 202 | 244 | 253 | 355   .   courses | advisees | faq | honesty | schedule   .   webHelp | unixHelp | c*Help | asmHelp

These standards are guidelines to help you write your code. Every organization has guidelines. These are mine. Please adhere to these guidelines - points will be deducted if you do not.


50-75% of a software system's cost is consumed by maintenance which includes fixing problems, adapting code to new environments and adding functionality. The readability of the program directly affects maintainability.


The following standards are meant to enhance readability. If you write great code, but the code is unmaintainable, you cost the company money and you are a liability. Yes, it takes more time initially to write maintainable code, but there is a large return on the investment.


C++ Coding Standards

Assembly Language Coding Standards

C# Coding Standards

 
 

 

 
 

 

 
 

 
 

 

 
 

 

 
 


C++ Coding Standards::

  • Header: All program files should begin with a header section that has three components.
    1. Identification: Name / Date/ Class/ Directory (if relevant) and File Name
    2. Purpose:
      Why is the program being written?
      What problem does it solve?
      A few sentences or a paragraph here.
    3. Algorithm:
      Detail the steps you are going to take to solve the problem according to the the purpose outlined above.
      Put some details here - not vague generalities.
      This is your plan of attack!
  • Body: The body of the code (the program statements) should be written to be readable.
    1. Meaningful names for variables, constants and functions. Names should reflect the purpose they have. A variable that holds a person's age should be called "age", not "x".
    2. Indenting to show the code affected by loops and if/else statements.
    3. White Space to make code readable. Use both horizontal and vertical white space.
    4. Comments that explain WHY things are being done when needed. Don't just repeat the obvious. Give the reader some insight.

      Use the steps from your algorithm to delineate sections of your program so there is a direct relationship between the algorithm and the code.


          Coins: Sample program: look at documentation.            LoopSum: sample program: look at documentation.

    Back to Top

     
     

     

     
     

     

     
     

     
     

     

     
     

     

     
     


    Assembly Language Coding Standards::

  • Header: All program files should begin with a header section that has three components.
    1. Identification: Name / Date/ Class/ Directory (if relevant) and File Name
    2. Purpose: Why is the program being written? What problem does it solve? A few sentences or a paragraph here.
    3. Algorithm: Detail the steps you are going to take to solve the problem according to the the purpose outlined above. Put some details here - not vague generalities. This is your plan of attack.
  • Body: The body of the code (the program statements) should be written to be readable.
    Some of the important issues to address are::
    1. Meaningful names for variables, constants and functions. Names should reflect the purpose they have. A variable that holds a person's age should be called "age", not "x".
    2. Indenting to show the code affecyed by loops and if/else statements.
    3. White Space to make code readable. Use both horizontal and vertical white space.
    4. Comments that explain WHY things are being done when needed. Don't just repeat the obvious. Give the reader some insight.

      Use the steps from your algorithm to delineate sections of your program so there is a direct relationship between the algorithm and the code.


      Example Program: Addsub

    Assembly is cryptic and so the burden to document is higher for you. Nothing is obvious in assembly language - document, document, DOCUMENT! Why, what and how are all important.

    An example:


                 bad:
    mov eax, 100h ; move 100h into eax
    better:
    mov eax, 100h ; move 256 into the eax register for loop control
    best:
    mov eax, 100h ; move number of records into the eax register
    ; which is used for loop control to determine the number
    ; of times that the processing code will execute

    Back to Top

     
     

     

     
     

     

     
     

     
     

     

     
     

     

     
     


    C# Coding Standards::

  • All Forms:
    Identification: Name / Date/ Class
    Form Organization: List names of all code routines with one sentence description.
          OR
    Each Event Procedure: Minimum one sentence description. Explain more as needed.

  • Main Form:
    All of the above PLUS:
    Program Purpose:Why is the program being written? What problem does it solve? A few sentences or a paragraph here.

  • Code Modules:
    Identification: Name / Date/ Class
    Module Organization: List names of all code routines with one sentence description.
    Each Procedure: Minimum one sentence description. Explain more as needed.

  • Generally:
    Explain WHY things are being done. Don't just repeat the obvious - give the reader some insight!
    Use meaningful names for variables, constants and functions.
    Use indenting to show loops and branches.
    Use white Space to make code readable.

    Back to Top