Difference between revisions of "Team Mighty Morphin Coding Rangers - OOP344"

From CDOT Wiki
Jump to: navigation, search
m (Updated page to include coding style of the team)
(Coding Style - updated the coding style (by DO))
Line 4: Line 4:
  
 
<ul>
 
<ul>
   <li>Comment as much as you can using /* ... */.</li>
+
   <li>Comment as much as you can using /* ... */. </li>
 +
  <ul>
 +
    <li>At the top of every file, include your name, the filename, and the purpose of the file.</li>
 +
 
 +
    <li>Comment on what a function is supposed to do before the function definition.</li>
 +
  </ul>
  
 
   <li>Change to newline once you reach <b>column 80</b>. Nothing to be typed beyond column 80!</li>
 
   <li>Change to newline once you reach <b>column 80</b>. Nothing to be typed beyond column 80!</li>
Line 10: Line 15:
 
   <li>When naming variables,  
 
   <li>When naming variables,  
 
     <ul>
 
     <ul>
     <li>use single letters (like i, j, a, or v) for counters only. </li>
+
     <li>use single letters (like i, j, a, or v) for counters only; </li>
     <li>assign the name that best describes what a variable is used for
+
     <li>assign the variable a name that best describes what it is used for (but please don't make it too long);</li>
      (but please don't make it too long)</li>
+
     <li>and separate words with caps.  
     <li>separate words with caps.  
+
<br/> Eg. no<b>O</b>f<b>O</b>rders, not no<b>o</b>f<b>o</b>rders
      <br />Eg. no<b>O</b>f<b>O</b>rders, not no<b>o</b>f<b>o</b>rders
 
 
     </ul>
 
     </ul>
 
   </li>
 
   </li>
  
   <li>Tabbing/Spacing: As most of us have decided to use vi, we have determined that <b>TABBING 2 SPACES</b> will be the norm.
+
   <li>When naming a function, name it according to what it is supposed to do.
 +
<br />Eg. <code>void updateDelivery, int setInitialValue</code>, not <code>void Deliveries, int InitialValues</code></li>
 +
 
 +
  <li>Class names must begin with a capital letter</li>
 +
 
 +
  <li>Tab/space two (2) spaces for every block of code. For example: </li>
 +
<code>
 +
  main () { <br/>
 +
    int x, y; <br/>
 +
    for (x = 0, y = 10; x < 10 && y > 0; x++, y++) { <br/>   
 +
      printf("x is %d, y is %d\n", x, y); <br/>
 +
      printf("The sum of x and y is %d\n", x + y); <br/>
 +
      if (x == 5)  <br/>
 +
        printf("We've reached the halfway point!\n");
 +
    } <br/>
 +
    printf("Hello, world!"); <br/>
 +
  } <br/>
 +
</code>
  
   <li>Only <code>main ()</code> will start at column 1. Tab everything else two spaces over</li>
+
   <li>Only <code>main ()</code> will start at column 1. Tab every block of code two spaces over.</li>
  
 
   <li>When using operators, make sure to have a space between the operands and the operator for readability.  
 
   <li>When using operators, make sure to have a space between the operands and the operator for readability.  
 
     <br/>Eg. <code>i = 0;</code>, not <code>i=0;</code></li>
 
     <br/>Eg. <code>i = 0;</code>, not <code>i=0;</code></li>
  
   <li>For keywords such as while, for, if, else, put a space after the keyword and the expression following it.  
+
   <li>For keywords such as <code>while, for, if, else, </code> put a space after the keyword and the expression following it.  
     <br/> Eg. if <code>(x==0)</code> is correct, not <code>if(x==0)</code></li>  
+
     <br/> Eg. <code>if (x == 0)</code> is correct; <code>if(x == 0)</code> is incorrect</li>  
  
   <li>When using brackets, put the opening bracket on the same line as the function or expression that opens it.  
+
   <li>When using brackets, put the opening bracket on the same line as the function or expression that opens it. <br/>
     <br/>Eg.
+
     Eg. <b>CORRECT: </b> <br/>
     <br/>int setSafeEmptyState {  
+
     <code>int setSafeEmptyState { <br/>
    <br/>...  
+
    ... <br/>
     <br/>} is correct
+
     } </code> <br/>
     <br/>int setSafeEmptyState  
+
     <b>INCORRECT: </b> <br/>
    <br/>{
+
    <code>int setSafeEmptyState <br/>
     <br/>...
+
     { <br/>
     <br/>} is incorrect
+
    ... <br/>
 +
     } </code> <br/>
 
   </li>
 
   </li>
 +
 
</ul>
 
</ul>

Revision as of 21:45, 22 January 2010

Coding Style

The Coding Rangers had their first somewhat informal meeting on Jan. 21 to determine a uniform coding style. They came up with the following:

  • Comment as much as you can using /* ... */.
    • At the top of every file, include your name, the filename, and the purpose of the file.
    • Comment on what a function is supposed to do before the function definition.
  • Change to newline once you reach column 80. Nothing to be typed beyond column 80!
  • When naming variables,
    • use single letters (like i, j, a, or v) for counters only;
    • assign the variable a name that best describes what it is used for (but please don't make it too long);
    • and separate words with caps.
      Eg. noOfOrders, not nooforders
  • When naming a function, name it according to what it is supposed to do.
    Eg. void updateDelivery, int setInitialValue, not void Deliveries, int InitialValues
  • Class names must begin with a capital letter
  • Tab/space two (2) spaces for every block of code. For example:
  •  main () { 
    int x, y;
    for (x = 0, y = 10; x < 10 && y > 0; x++, y++) {
    printf("x is %d, y is %d\n", x, y);
    printf("The sum of x and y is %d\n", x + y);
    if (x == 5)
    printf("We've reached the halfway point!\n"); }
    printf("Hello, world!");
    }

  • Only main () will start at column 1. Tab every block of code two spaces over.
  • When using operators, make sure to have a space between the operands and the operator for readability.
    Eg. i = 0;, not i=0;
  • For keywords such as while, for, if, else, put a space after the keyword and the expression following it.
    Eg. if (x == 0) is correct; if(x == 0) is incorrect
  • When using brackets, put the opening bracket on the same line as the function or expression that opens it.
    Eg. CORRECT:
    int setSafeEmptyState {
    ...
    }

    INCORRECT:
    int setSafeEmptyState
    {
    ...
    }