Difference between revisions of "CpaCoderpz - oop344 20123"

From CDOT Wiki
Jump to: navigation, search
(Coding Rules)
Line 84: Line 84:
  
 
== Coding Rules ==
 
== Coding Rules ==
 +
'''General'''
 +
* tab four (4) spaces
 +
* do not cut off long lines
 +
* use spaces and not tabs
 +
* ordering rules may be broken if needed for functionality or practicality
 +
 +
'''Naming'''
 +
* private variables and methods must start with an underscore (_)
 +
* variable names use camel case starting with a lowercase letter (variableName)
 +
* method and function names use camel case starting with a lowercase letter (methodName)
 +
* class names use camel case starting with an uppercase letter (ClassName)
 +
* constant names are all uppercase and words are split with an underscore (CONSTANT_NAMES)
 +
 +
'''Variables'''
 +
* in classes, order variables by type and then name unless an alternate order is required to function
 +
* primitive before non primitive
 +
* with primitive types, largest to smallest
 +
* order non primitive types alphabetically
 +
 +
'''Classes'''
 +
* in class interfaces everything is indented at least one level
 +
* in class interfaces in scopes that are specified, indent the method and variable declarations in that scope an additional level
 +
* declare variables before methods in a scope
 +
* variable names are not included in the interface
 +
* method comments are in the implementation
 +
* variable comments are in the interface
 +
* constructors and destructors are declared first in their scope
 +
 +
<pre>class ExampleClass {
 +
    int _privateVariable;
 +
    public:
 +
        bool status;
 +
        int something(int);
 +
};</pre>
 +
 +
'''Conditional Statements'''
 +
* else and else if statements take place the line after a closing bracket
 +
* no break on default case in switch statement
 +
* in switch statement, break statements share the same indent level as a case statement
 +
* always use brackets, even with single line statements
 +
 +
<pre>if (false) {
 +
    statement;
 +
}
 +
else {
 +
  statement;
 +
}
 +
 +
switch (1) {
 +
    case 2:
 +
        statement;
 +
    break;
 +
    default:
 +
        statement;
 +
}</pre>
 +
 +
'''Loops'''
 +
* in for loops, use the letter i to count iterations
 +
* in nested for loops, use alphabetically increased letters from the letter i as iteration counters (i, j, k, ect)
 +
* always use brackets or ; to declare that there is no code to be run each loop
 +
 +
<pre>for (int i = 0; i < 10; i++);</pre>
 +
 +
<pre>for (int i = 0; i < 10; i++) {
 +
    for (int j = 0; j < 10; j++) {
 +
        statement;
 +
    }
 +
}</pre>
 +
 +
'''Comments'''
 +
* comments for variables take place on the same line as the variable
 +
* method and function comments must always be multi-line comments
 +
* method and function comments describe the method or function and then specify the the parameters and return with a short description (if needed) of each
 +
* code blocks of over 20 lines can have their end bracket commented
 +
 +
<pre>/*
 +
* increases a number by 1
 +
*
 +
* param: num, the integer number to increase
 +
* return: num increased by 1
 +
*
 +
*/
 +
int func(int num) {
 +
    return num + 1;
 +
}</pre>
 +
 +
'''Spacing'''
 +
* if, for, switch and while statements are followed by a space before the open parentheses
 +
* the close parentheses for these statements is followed by a space before the open curly bracket
 +
* when the parentheses is followed by a semicolon, there is no space
 +
* in for statements, each semicolon is followed by a space unless it is empty
 +
* for method and function declaration, there is no space between the end of the name and the open parentheses
 +
 +
<pre>switch (1) {
 +
    case 2:
 +
        statement;
 +
    break;
 +
    default:
 +
      statement;
 +
}</pre>
 +
 +
<pre>if (true) {
 +
    statement;
 +
}
 +
else if (false) {
 +
    statement
 +
}
 +
else {
 +
    statement;
 +
}</pre>
 +
 +
<pre>for (int i = 0; i < 10; i++);
 +
 +
while (false) {
 +
    statement;
 +
}
 +
 +
do {
 +
  statement;
 +
} while (true);</pre>
 +
 +
'''Includes'''
 +
* order includes in order of priority then alphabetically
  
 
== meetings ==
 
== meetings ==

Revision as of 14:02, 2 November 2012


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

cpaCoderpz (team X)

Project Marking Percentage

  • due immediately

Group work:      XX%        (25 <= xx <= 50)
Individual work: XX% +      (50 <= xx <= 75) 
-------------------------
Total           100%

Repository

  • repo Github id:



Team Members

cpaCoderpz members
First Name Last Name Team Name Section Seneca Id wiki id IRC nick GITHUB ID Blog URL
Freddy Cheungh cpaCoderpz A fgcheunghchen1 Freddy Gai Fung Cheungh Chen fgcheunghchen1 fgcheunghchen1 Freddy's C++ Blog
Matt Jang cpaCoderpz A mjang13 Matt Jang SoBrisk SoBrisk Matt's Blog
Vernileo Turalba cpaCoderpz A vturalba Leo Turalba Ltur leoturalba Blogging Coderz
Joseph Visconti cpaCoderpz B jvisconti2 Joseph_Visconti Visconti Joseph-Visconti OOP344

Issues and Status

Issue description and/or number (1)

  • Status:
  • (being developed/pull request/being reviewed/pushed to master)
  • comments:

Issue description and/or number (2)

  • Status:
  • (being developed/pull request/being reviewed/pushed to master)
  • comments:

Coding Rules

General

  • tab four (4) spaces
  • do not cut off long lines
  • use spaces and not tabs
  • ordering rules may be broken if needed for functionality or practicality

Naming

  • private variables and methods must start with an underscore (_)
  • variable names use camel case starting with a lowercase letter (variableName)
  • method and function names use camel case starting with a lowercase letter (methodName)
  • class names use camel case starting with an uppercase letter (ClassName)
  • constant names are all uppercase and words are split with an underscore (CONSTANT_NAMES)

Variables

  • in classes, order variables by type and then name unless an alternate order is required to function
  • primitive before non primitive
  • with primitive types, largest to smallest
  • order non primitive types alphabetically

Classes

  • in class interfaces everything is indented at least one level
  • in class interfaces in scopes that are specified, indent the method and variable declarations in that scope an additional level
  • declare variables before methods in a scope
  • variable names are not included in the interface
  • method comments are in the implementation
  • variable comments are in the interface
  • constructors and destructors are declared first in their scope
class ExampleClass {
    int _privateVariable;
    public:
        bool status;
        int something(int);
};

Conditional Statements

  • else and else if statements take place the line after a closing bracket
  • no break on default case in switch statement
  • in switch statement, break statements share the same indent level as a case statement
  • always use brackets, even with single line statements
if (false) {
    statement;
}
else {
   statement;
}

switch (1) {
    case 2:
        statement;
    break;
    default:
        statement;
}

Loops

  • in for loops, use the letter i to count iterations
  • in nested for loops, use alphabetically increased letters from the letter i as iteration counters (i, j, k, ect)
  • always use brackets or ; to declare that there is no code to be run each loop
for (int i = 0; i < 10; i++);
for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
        statement;
    }
}

Comments

  • comments for variables take place on the same line as the variable
  • method and function comments must always be multi-line comments
  • method and function comments describe the method or function and then specify the the parameters and return with a short description (if needed) of each
  • code blocks of over 20 lines can have their end bracket commented
/*
 * increases a number by 1
 *
 * param: num, the integer number to increase
 * return: num increased by 1
 *
 */
int func(int num) {
    return num + 1;
}

Spacing

  • if, for, switch and while statements are followed by a space before the open parentheses
  • the close parentheses for these statements is followed by a space before the open curly bracket
  • when the parentheses is followed by a semicolon, there is no space
  • in for statements, each semicolon is followed by a space unless it is empty
  • for method and function declaration, there is no space between the end of the name and the open parentheses
switch (1) {
    case 2:
        statement;
    break;
    default:
       statement;
}
if (true) {
    statement;
}
else if (false) {
    statement
}
else {
    statement;
}
for (int i = 0; i < 10; i++);

while (false) {
    statement;
}

do {
   statement;
} while (true);

Includes

  • order includes in order of priority then alphabetically

meetings

  • latest will be on top
  1. topic and date1
  1. topic and date2

discussions