|
Home My Resume JComp Films Standards My Blog |
I started my professional life at Cognizant Technology Solutions, a software services company. During my tenure, I faced several projects in which I have to analyze thousands of lines of code in a very short time. In these tasks, I have realized that coding standards are more, if not the most, important aspect of the programming. So, I follow a set of coding standards in all my programs, irrespective of the language. Usually, I try to develop programs that would adhere to 'Code Conventions for the Java Programming Language'. In addition, I have added some more rules so my programs would be more useful. The list is provided below: This page would be referenced in all my programs. 1. The variable names will always be descriptive. For example, the radius of the circle will be identified by radius_Circle. The input array of numbers to be sorted (in a sorting program) will be identified by input_array. The input array of numbers to be sorted (in a bigger program) will be identified by input_sorting_array. 2. There could be temporary variables that can be used for incrementing in the for loops, temporary place holders, etc. The names of these variables will start with 'temp_'. For example, a incremental variable will be identified by temp_increment_variable. 3. The variable names like i, j, k, fp, fr etc will never be used. 4. Though the declaration of the variables in between the programs is allowed in languages like Java, I will not use that feature. In almost all of my programs, all the variables will be declared at the beginning (of the class/procedure) with a short comment of their functionality. 5. Usually, the operators '++', '--', '+=', '-=' are avoided. The usage of these operators, though appears handy at first, becomes annoying during the debugging and analysis of the program. 6. Usually, the indentation will be 8 characters. 7. I do not prefer using 'else if' as one. The else and if will always be in separate lines. 8. A block of comments will be added before each function. This will have the function name, parameters to the function, function logic, return value, etc. 9. The hard coding will be avoided in most cases. Wherever possible, the values to be hard coded will be either moved to database tables or files. In simple programs, they will be defined in the variables and used in the programs. 10. Wherever possible there will be one class/function in one file. |