Changes

Jump to: navigation, search

Team Excellence - oop344 20113 Code Standards

1,273 bytes added, 23:53, 18 October 2011
Class Standards
{{OOP344 Index | 20113}}
=Code Standards=Fardad suggested in class today that we make '''Sandip:'''I have a document that defines the format that our code is presented in so I've made proposal. How about doing it like this page to outline them.:==If Statement==  '''Dzmitry:'''I have a proposal. How about doing it like this:
<syntaxhighlight lang="cpp">
if (condition){ stuff;}else if (condition){ stuff;}else { stuff;
}
</syntaxhighlight>
Notice the That will save a few lines, also space between the 'if' and '(' "stuff" and the lack beginning of a space between the 'line should be default Visual Studio Tab (Mine is 4 spaces)' and '{'. Also the 'else' starts a line under the '}'.
If the "stuff" is only '''Jitender:'''Guys, we should agree one line of the curly braces can be omitted.standard, I agree with Dzmitry proposal, it short and easy to follow ==For Loop==
<syntaxhighlight lang="cpp">
for (i=0; condition; i++){
Similar deal as with the if statement if "stuff" is only one like the curly braces can be omitted.
 ==While Loop==
<syntaxhighlight lang="cpp">
while (true){
Also the curly braces can be omitted if "stuff" is only one line.
 ==Function Declarations==
<syntaxhighlight lang="cpp">
void foo(int a){
Also there's no space between the ')' and '{'.
 ==Indents==
I think each indent should be the equivalent of two spaces. You can change the settings of Visual Studio to put in 2 spaces whenever you press tab. This will keep the code properly aligned and if someone isn't used to using tab for indent they can easily just use two spaces.
 '''Dzmitry:''' I think at least 3-4 spaces will be better. First of all, it makes code easier to read (less characters on a page) and original console.cpp (at least for me) is written with 4 spaces spacing, so we won't need to change professor's code. ==Class Member VariablesStandards ==I think we should follow Fardad'''Header File Standards:'''s lead and start all of our <syntaxhighlight lang="cpp">/*** class.h* Sandip Patel * October 12, 2011**/ #ifndef _INITIAL_CLASS_#define _INITIAL_CLASS_ classCLASS { int _a; int _b;  public: function();} #endif</syntaxhighlight> '''All Cpp File Standards:''' member variable names with <syntaxhighlight lang="cpp"> /* Function Starts here */function name() {  /* Header goes here */ int key = 0; // Comment goes here bool done = false;  /* Again Important Header goes here */ if(condition){ stuffs; }  /* All Loops */ for(i=0; i<len; i++){ statements; } while(condition){ statements; } }/* function ends here */</syntaxhighlight> == Comments =='''Dzmitry:'''<syntaxhighlight lang="cpp">int foo(int x); // this comment is an underscore example</syntaxhighlight> == File Header == '_' to differentiate them from other variables'Suggested By: Sandip Patel'''<syntaxhighlight lang="cpp">/*** test.cpp* Sandip Patel * October 12, 2011**/</syntaxhighlight>

Navigation menu