= Official Standards =
Below are the standards that our team will follow while programming our project. As stated during our IRC meeting, these standards may be changed if the team deems necessary.
LIST STANDARDS HERE= Declare only one variable in each line. = This makes it easier to scan the code and find the type of a variable that you see somewhere else in the code. Do: int a; int b = 0; int c = a; Don't: int a, b = 0, c = a; = Indentation = Indent = 2 spaces The tab space is interpreted different across different software and operating systems. Use normal spaces to add indentation instead. Note : Most text editors have the option to switch tabs into spaces, this helps so you don't have to press the space so many times. = Use Include Guides for Header Files = For every header file that we write, we must make sure that it will never be added more than once to different pieces of code. Therefore, all your header file code should be in between the include guides as shown below: #ifndef _344_EXAMPLE_H_ #define _344_EXAMPLE_H_ (code) #endif The convention for this project is to define our header files in upper case, starting with 344, and enclosed in a single underscore(_) = Put the pointer identifier(*) right after the target variable type. = Pointers are hard enough to deal with. It only makes it more complicated if they are declared differently throughout the code. Do: int* p1; char* p2; Don't: int *p1; char *p2; = Use of iterating variables on for loops = Since we will be writing code in both C and C++, we must declare all of our variables at the top of the program, including iteration(for loop) variables. Do: int i; for(i = 0; i < 5; i++) { .. }Don't: for(int i = 0; i < 5; i++) { .. } = Variable names = We will be using small camel notation for variable names. Use descriptive names, and allowed to use abbreviations when obvious. Do: int numOfStudents; int studNumber; char* firstName char* lastName Don't: int NumberOfStudents; int StudentNumber; char* StudentFirstName; char* StudentLastName; = Use of comments =Since we will be writing code in C and C++, we MUST only use /* comment */ for comments. Native C compilers do not know how to handle end of line comments(//), so please don't use them. = Nesting and Block Format = Here is how we are going to deal with nesting statements, also where we are going to be placing the braces. Do: if(something == 1) { printf("something = 1\n"); } else { printf("something != 1\n"); }Above you see that we have the '''else''' statement on it's own line. We also have the opening brace on the same line as our statement. = CONST vs. DEFINE =We have decided to use const instead of the define command. Const allows us to define a type, which allows for better error messages when trying to debug the code. Do: const int CONTANT = 100;Don't: #define CONSTANT;