Difference between revisions of "OOP344 - HOTYS - 20102"

From CDOT Wiki
Jump to: navigation, search
(Coding Style Rules: v5 more rules added)
(Coding Style Rules: Final Version)
Line 45: Line 45:
  
 
==<big>Coding Style Rules</big>==
 
==<big>Coding Style Rules</big>==
<pre>
+
Every file should have a function header with:<br />
Every file should have a function header with:
+
<ul>
File name
+
  <li>File name</li>
Programmer Full name
+
  <li>Programmer Full name</li>
Date last modified
+
  <li>Date last modified</li>
 +
</ul>
  
Variable names should be meaningful so additional comments are not necessary to explain what the variable does
+
Example:<br />
 +
<div>
 +
<b style="color: #008800; line-height: 0.5em;">
 +
  /*<br />
 +
  Title<br />
 +
  Title.h<br />
 +
  By: Full Name<br />
 +
  Date Last Modified: 9:59 AM April-15-10<br />
 +
  Description of what is in the file<br />
 +
  */<br />
 +
</b>
 +
</div>
 +
<br />
 +
 
 +
Variable names should be meaningful so additional comments are not necessary to explain what the variable does.
 +
 
 +
Example:
 +
<div>
 +
<b style="color: #000000; line-height: 0.5em;">
 +
  int nNum; <span style="color: #008800;">//Bad</span><br />
 +
  int nNumOfTypes <span style="color: #008800;">//Good</span><br />
 +
</b>
 +
</div>
 +
<br />
  
 
A lower case prefix should be fitted to the variable name to help describe it at a glance:
 
A lower case prefix should be fitted to the variable name to help describe it at a glance:
n int
 
c character
 
b Boolean
 
f fload
 
d double
 
s C-style null terminated string OR a string object
 
p Pointers
 
  
Ex:
+
<table border="1" cellspacing="3" cellpadding"5">
nNumOfSignals
+
  <tr style="border: 1px solid #000000; text-align: center;">
cCharPassed
+
      <th>Prefix</th>
bIsTrue
+
      <th>Data Type</th>
fLength
+
      <th>Example</th>
dWidth
+
  <tr style="border: 1px solid #000000; text-align: center;">
sUserInput
+
      <td>n</td>
pnNumOfSignals
+
      <td>int</td>
 +
      <td>nNumOfSignals</td>
 +
  </tr>
 +
  <tr style="border: 1px solid #000000; text-align: center;">
 +
      <td>c</td>
 +
      <td>char</td>
 +
      <td>cTypeMode</td>
 +
  </tr>
 +
  <tr style="border: 1px solid #000000; text-align: center;">
 +
      <td>b</td>
 +
      <td>boolean</td>
 +
      <td>bIsTrue</td>
 +
  </tr>
 +
  <tr style="border: 1px solid #000000; text-align: center;">
 +
      <td>f</td>
 +
      <td>float</td>
 +
      <td>fLength</td>
 +
  </tr>
 +
  <tr style="border: 1px solid #000000; text-align: center;">
 +
      <td>d</td>
 +
      <td>double</td>
 +
      <td>dWidth</td>
 +
  </tr>
 +
  <tr style="border: 1px solid #000000; text-align: center;">
 +
      <td>s</td>
 +
      <td>C-Style null terminated string<br />OR a String object</td>
 +
      <td>sUserInput</td>
 +
  </tr>
 +
  <tr style="border: 1px solid #000000; text-align: center;">
 +
      <td>p</td>
 +
      <td>pointers</td>
 +
      <td>pnNumOfSignals</td>
 +
  </tr>
 +
  <tr style="border: 1px solid #000000; text-align: center;">
 +
      <td>m_</td>
 +
      <td>Data Member/<br />Instance Variable</td>
 +
      <td>m_pnNumOfSignals<br /><b>NOT</b><br />pnm_NumOfSignals<br /><b>OR</b><br />mpn_NumOfSignals</td>
 +
  </tr>
 +
</table>
 +
 
 +
All variable declarations should be done on their own lines!
  
Also for Classes, ALL Data Member should have a m_ prefixed to the name to show that it is a Data Member ( Instance Variables )
+
There should be NO single character names for variables (Ex: i, j, k, etc) except for arbitrary counters, such as for for loops
Ex:
 
int m_nType;
 
NOT
 
int nm_Type OR INT mn_Type;
 
  
All variable declaration should be done on it's own line
+
All const and #define Variable names should be in All Caps
  
There should be NO single character names for variables (Ex: i, j, k, etc) except for arbitrary counters, such as for loops
+
Example:<br />
 +
<div>
 +
<b style="color: #000000; line-height: 0.5em;">
 +
  const int nMAX_TRIPS;<br />
 +
  #define MAX_TRIPS 1<br />
 +
</b>
 +
</div>
 +
<br />
  
All const and #define Variable names should be in All Caps
 
ex:
 
const int MAX_TRIPS;
 
#define MAX_TRIPS 1
 
  
Pointers should be defined in C++ style:
 
int* x;
 
NOT
 
int * x; OR int *x;
 
  
 +
Pointers should be declared in C++ style:
 +
 +
Example:<br />
 +
<div>
 +
<b style="color: #000000; line-height: 0.5em;">
 +
  int* x;<br />
 +
  NOT<br />
 +
  int * x; OR int *x;<br />
 +
</b>
 +
</div>
 +
<br />
 +
 +
Class names should be all lower case except for the first letter, which should be upper case.
 +
 +
Function names should have meaningful names (They do not require prefix).
  
Function names should have meaningful names (they do not require prefix)
 
 
Function names Should be all lower case except for the First letter of each Word.
 
Function names Should be all lower case except for the First letter of each Word.
Each function should have only one point of entry and one point of exit.
+
 
I.E. There should be only 1 return statement in each function.
+
Example:<br />
 +
<div>
 +
<b style="color: #000000; line-height: 0.5em;">
 +
  GetChar();<br />
 +
  NOT<br />
 +
  getChar(); OR Getchar();<br />
 +
</b>
 +
</div>
 +
<br />
 +
 
 +
 
 +
Each function should have only one point of entry and one point of exit! I.E. There should be only 1 return statement in each function.
  
 
Each function should have a header describing what it does.
 
Each function should have a header describing what it does.
  
 
Use Inline comments to describe hard to read code.  All inline code should be set to the same indention as the code it is describing.  
 
Use Inline comments to describe hard to read code.  All inline code should be set to the same indention as the code it is describing.  
 +
 +
Example:<br />
 +
<div>
 +
<b style="color: #000000; line-height: 0.5em;">
 +
    //Comment<br />
 +
    GetChar();<br  />
 +
    NOT<br />
 +
//Comment<br />
 +
    GetChar()<br />
 +
</b>
 +
</div>
 +
<br />
  
  
 
Opening braces should be on the same line as the defining function/if/else if/etc statement.
 
Opening braces should be on the same line as the defining function/if/else if/etc statement.
Ex:
 
void FunctionOne(int){
 
if (x > y){
 
NOT
 
void FunctionOne(int)
 
{
 
if (x > y)
 
{
 
  
 +
Example:<br />
 +
<div>
 +
<b style="color: #000000; line-height: 0.5em;">
 +
  void FunctionOne(int){<br />
 +
      if (x > y){<br />
 +
  NOT<br />
 +
  void FunctionOne(int)<br />
 +
  {<br />
 +
      if (x > y)<br />
 +
      {<br />
 +
</b>
 +
</div>
  
 +
<b>
 
There should be NO use of the tab character!!!
 
There should be NO use of the tab character!!!
 
Each indent should be 3 blank spaces!  I will write a wiki on how to set this up in VS 2008, VS 2010,And Notepad++
 
Each indent should be 3 blank spaces!  I will write a wiki on how to set this up in VS 2008, VS 2010,And Notepad++
 +
</b>
  
  
 
</pre>
 
  
 
<br /> <br />
 
<br /> <br />

Revision as of 18:39, 23 May 2010


OOP344 | Weekly Schedule | Student List | Teams | Project | Student Resources

This is team HOTYS homepage!!!

The Name of the team is derived from the first letter of each group member's name:

Han Chul Kim
Osman Mirza
Tony Kim
YuJin Jeong
Stephanie Law


Member List

OOP344 - 2010 Team HOTYS -
Last
Name
Name Seneca
Username
Section Blog Url IRC Nick My Contributions
a Kim Han hckim3 A http://hckim.wordpress.com/ han3 Hckim3
b Mirza Ozzy omirza A http://0zzym.wordpress.com/ OzZy_M OzZy
c Kim Tony kjkim A My Blog TonyKim kjkim
d Jeong YuJin yjeong A Spirit & Soul YuJin Takeiteasy
e Law Stephanie slaw12 - A My Blog- Slaw12 slaw12

Team Project

Team Project


Discussions

Discussion Page


IRC Schedule/Log

IRC Page

Coding Style Rules

Every file should have a function header with:

  • File name
  • Programmer Full name
  • Date last modified

Example:

  /*
Title
Title.h
By: Full Name
Date Last Modified: 9:59 AM April-15-10
Description of what is in the file
*/


Variable names should be meaningful so additional comments are not necessary to explain what the variable does.

Example:

  int nNum; //Bad
int nNumOfTypes //Good


A lower case prefix should be fitted to the variable name to help describe it at a glance:

Prefix Data Type Example
n int nNumOfSignals
c char cTypeMode
b boolean bIsTrue
f float fLength
d double dWidth
s C-Style null terminated string
OR a String object
sUserInput
p pointers pnNumOfSignals
m_ Data Member/
Instance Variable
m_pnNumOfSignals
NOT
pnm_NumOfSignals
OR
mpn_NumOfSignals

All variable declarations should be done on their own lines!

There should be NO single character names for variables (Ex: i, j, k, etc) except for arbitrary counters, such as for for loops

All const and #define Variable names should be in All Caps

Example:

  const int nMAX_TRIPS;
#define MAX_TRIPS 1



Pointers should be declared in C++ style:

Example:

  int* x;
NOT
int * x; OR int *x;


Class names should be all lower case except for the first letter, which should be upper case.

Function names should have meaningful names (They do not require prefix).

Function names Should be all lower case except for the First letter of each Word.

Example:

  GetChar();
NOT
getChar(); OR Getchar();



Each function should have only one point of entry and one point of exit! I.E. There should be only 1 return statement in each function.

Each function should have a header describing what it does.

Use Inline comments to describe hard to read code. All inline code should be set to the same indention as the code it is describing.

Example:

   //Comment
GetChar();
NOT
//Comment
GetChar()



Opening braces should be on the same line as the defining function/if/else if/etc statement.

Example:

  void FunctionOne(int){
if (x > y){
NOT
void FunctionOne(int)
{
if (x > y)
{

There should be NO use of the tab character!!! Each indent should be 3 blank spaces! I will write a wiki on how to set this up in VS 2008, VS 2010,And Notepad++