EMAN2 Coding Style

  1. Introduction
    1. This document summarizes the basic coding and naming style in EMAN2. The intended audiences are EMAN2 developers.
    2. This document is not a programming tutorial. You may refer the references at the end of document for good books.

  2. Overview
  3. Coding:
    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;
    4. All parameter names use lower case with '_' if necessary.

  4. 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:

  5. Comments
  6. 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. * @exception ImageDimensionException If the image is 3D. */ 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); private: int count; }
  7. References


Last modified on 9/30/2006 by Grant Tang (gtang@bcm.edu)