User Tools

Site Tools


coastalme_coding_standards

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
coastalme_coding_standards [2016/10/23 13:14]
coastalmeadmin
coastalme_coding_standards [2016/10/23 14:41]
coastalmeadmin
Line 5: Line 5:
  
 ===== Names ===== ===== Names =====
-Class in CoastalME begin with C and are formed using [[https://en.wikipedia.org/wiki/Camel_case|camel case]].+Class in CoastalME begin with C and are formed using [[https://en.wikipedia.org/wiki/Camel_case|CamelCase]].
  
 Examples: Examples:
Line 13: Line 13:
   * CCoastLanform   * CCoastLanform
   * [[http://www.coastalme.org.uk/doxygen/html/annotated.html|see all Classes here]]   * [[http://www.coastalme.org.uk/doxygen/html/annotated.html|see all Classes here]]
 +
 +
 +===== Members =====
 +
 +
 +Class member names begin with a lower case "m_" followed by variable name using Hungarian notation. A variable name starts with a group of lower-case letters which are mnemonics for the type that variable, followed by whatever name the programmer has chosen; this last part is sometimes distinguished as the given name. The first character of the given name should be capitalized to separate it from the type indicators.
 +
 +Examples:
 +
 +  * m_bBasementElevSave: boolean "b" 
 +  * m_nXGridMax: integer "n" 
 +  * m_GDALWriteIntDataType: GDAL data type "GDAL"
 +  * m_lGDALMinCanWrite: long "l"
 +  * m_ulNumCells: unsigned long "l"
 +  * m_dCellSide: double "d"
 +  * m_ldGTotPotentialPlatformErosion: long double "ld"
 +  * m_strCMEDir: string "str"
 +  * m_tSysStartTime: time_t "t"
 +  * m_VbConsChangedThisIter: vector boolean "Vb"
 +  * m_VnProfileToSave: vector integer "Vn"
 +  * m_VdSliceElev: vector double "Vd"
 +  * m_VstrInitialFineUnconsSedimentFile: vector string "Vstr"
 +  * m_VPoints: vector of C2DPoint "VPoints"
 +  * m_LCoastline: a variable of CLine "L"
 +  * ... 
 +
 +**Pointers** are denoted by a lowercase "p" before the variable type:
 +
 +  * m_pRasterGrid: a pointer of a RasterGrid object
 +  * m_pVCoastPolygon: a pointer to a Vector of CoastPolygons
 +  * pSim: a pointer to a CSimulation  
 +  * pPtVGetPoints: a pointer to a C2DPoint
 +  * ...
 +
 +An exception to this rule are ofstream type variables being the format of ofstream: **VariableNAmeStream** 
 +
 +Examples of ofstream variables:
 +  * SedLoadTSStream
 +  * StillWaterLevelTSStream
 +  * ErosionTSStream
 +  * DepositionTSStream
 +  * SedLostTSStream
 +
 +Class members can be public or private.
 +
 +===== Accessor Functions =====
 +
 +
 +Class member values should be obtained through accesssor functions. The function should be named with an indicative prefix (i.e. Set, Get,...). Examples of accessor functions for the private member variable m_dBasementElevation would be:
 +
 +  * dGetBasementElev(): function with a double return code
 +  * SetBasementElev(double const): function to set a double member variable
 +
 +===== Functions =====
 +
 +Function names begin with a lowercase letter and are formed using mixed case. The function name should convey something about the purpose of the function.
 +
 +  * bWriteProfileData()
 +  * nDoAllWaveEnergyToCoastLandforms()
 +  * ...
  
  
coastalme_coding_standards.txt ยท Last modified: 2016/10/23 14:41 by coastalmeadmin