+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ This is a document which describe preferred coding style for IWOR. You don't have to obey these rules (coding style is very personal) but at least consider the points made here. +--- GENERAL NOTES --------------------------------------------------+ First of all, keep the source clear and simple. Simple and clear code is better than complex and wonderful one. use indentation, empty line between statements and such that which make code more readable. And comments, comments and comments! Add comments everywhere, to make it clear what this particular part of code doing. But avoid over-commenting. Never do "nothing" silently: for (index = 0; data[index] < key; index++); // Did you see the semicolon at the end of the last line? Always put in a comment: for (index = 0; data[index] < key; index++){ //Do Nothing } Also break long lines into several ones. Preferred length of a line is 70 columns. Longer lines should be broken in two or more. +--- PLACING BRACES -------------------------------------------------+ Use brace around any statement, even an if statement which contain only one line. For example: if (A == B){ C == A; } Don't use something like: if (A == B) C == A; Especially for a For statement: for (int i=0;i<10;i++){ for(int j=0;j<10;j++){ //Do something } } Always use those braces. Don't put closing brace at the end of a line. Put it at the first of the next and empty line. Don't put anything after closing brace, it will confuse the reader. There are some technical reasons for choose a strategy over others, but this way of using brace is preferred. There is an exception for else statement. Use something like: if (A == B){ C == A; }else{ C == B; } +--- NAMING ---------------------------------------------------------+ Always use clear and expressive names. Don't use something like 'tmp', use 'tempCounter' instead. There's an exception for local variables. If you have a integer counter, use 'i' for its name rather than 'loop_counter'. Unless there's a chance of mis-understood. Name of variables and methods should start with a small letter, and classes with capital one. +--- PRINTING OUT MESSAGES ------------------------------------------+ As we know, the standard size of a terminal is 25x80. Don't print out long lines more than 80 columns. If you want to print out some information which useful for debuggers (not end users) put them in a '#ifdef DEBUG' section: #ifdef DEBUG //Debugging message. #endif In this case, nobody would see them unless she/he pass -DDEBUG argument to the compiler. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+