next up previous contents index
Next: Using Factory Classes Up: Developer's Guide Previous: Development Policy FAQ   Contents   Index


Coding Style

  1. Introduction
  2. Overview

    1. Coding:
      1. EMAN2 follows the GNU coding style with minor changes. We use indent at http://www.gnu.org/software/indent/indent.htmlhttp://www.gnu.org/software/indent/indent.html for beautifying EMAN2 code.
    2. Naming:
      1. All source code files use lower cases.
      2. All classes and data types use uppercase in the first letter;
      3. All functions use lower cases with '_' if necessary.

  3. indent HowTo
    1. install indent. (for linux, rpm is available from standard distribution.)
    2. save file .indent.pro to your home directory.
    3. say you have a file called ``foo.C'', run indent like this: indent foo.C

    4. because indent is designed for C code, it is not perfect for C++ code. Read your new source and fix the following possible errors:

      1. change 'const const' to 'const'

  4. Comments

    Use Doxygen JavaDoc style:

    /** Brief description which ends at this dot. Details follow here.\\ 
     */\\ 
    class Test\\ 
    {\\ 
    public:\\ 
    	/** The constructor's brief description in one line.\\ 
    	 * A more elaborate description of the constructor.\\ 
    	 */\\ 
    	Test();\\ 
    \\ 
    	/** do some test.\\ 
    	 * @author Liwei Peng <lpeng@bcm.tmc.edu>\\ 
    	 * @date 1/20/2005\\ 
    	 * @param low the low threshold.\\ 
    	 * @param high the high threshold.\\ 
    	 * @return 0 if do_test succeeds; 1 if do_test fails.\\ 
    	 */\\ 
    	int do_test(float low, float high);\\ 
    \\ 
    	/** Calculate the sum of an array.\\ 
    	 * @param[in] data Data array\\ 
    	 * @param[in] nitems Number of items in the array.\\ 
    	 * @param[out] sum The sum of the array.\\ 
    	 */\\ 
    	void calc_sum(int[] data, int nitems, int *sum);\\ 
    	\\ 
    }\\
    

  5. Samples
    1. ./html/emdata_8h-source.htmlemdata.h
    2. ./html/emdata_8cpp-source.htmlemdata.cpp

  6. References

Last modifiedby Liwei Peng (lpeng@bcm.tmc.edu)


next up previous contents index
Next: Using Factory Classes Up: Developer's Guide Previous: Development Policy FAQ   Contents   Index
2013-06-11