|
|
| Home About This Site Academic Policies Academic Staff Courses Curiosity Corner High School Computer Clubs Project Lab Rules Links Member Help News Other Stuff Standards Project Doc. Resource 111 Doc. Standards Java CodingStyle (pdf) Programming Standards Programming Standards Draft Report Guideline Rules For Good Programming Sortlistweek6 (pdf) Turing Days Usage Statistics Yarışma |
Programming standards (draft) This is intended to be a proposal for a joint coding standard for all the C family programs written in the department. So with some differences marked in the text, this should cover C, C++, Java, PHP and the other languages that resemble C syntactically As these are suggestions I have indicated preferences by reference to
exiting standards.
Indentation and bracketing.GNU style curly brackets (start on a new line), Torvalds style indentation ( tabs, tab set to 8).All other layout Torvalds style. NamingClasses (C++ and Java) start with a big letter.methods, functions, variables start with a small letter inFixCaps style (Each new word in a name starts with a big letter). No underscores in names. local variable names should be short, class level and/or global names should be descriptive functions and method names should start with a verb. variable names should start with a noun. constants (Java statics) should be all caps (big letters) set and get methods (C++ and Java) should be given anme sthat start with "set" and "get" ReadabilityDo not use switch, do..while, break, goto.Always curly bracket the clause following while, if, for, even it is only one statement. Only use for for definite iteration - no "clever" programming with the for loop. Only use global variables (or class level variables between methods in Java and C++) when absolutely necessary. (This is genrally only true when interfacing to code that you do not control -counting the number of times qsort calls compare is a good example) Always use access methods to "set" and "get" Class variables in Java and C++, even inside the class. CommentsEvery method and function ( except simple set and get methods and one line functions) should be preceded by a comment block in Sun Java style:-/**
The comment block should include:
Comments within functions/methods should be // style (this allows commenting out of blocks of code safely). Follow the Sun Java recommendations about alignement and spacing. Data declarations of class level and global variables and constants (statics in Java) should be fully commented in // style with clear statements of valid value ranges and the meanings of the values. Local vraibale should only be commented when the meaning is not clear ( making it clear wouldbe a better alternative.) |
Last Updated : 2002-03-24 14:16:23
|