wiki:coding_rules

Version 3 (modified by Mathieu Morlighem, 14 years ago) ( diff )

more guidelines

General guidelines

  • comment your code extensively (everybody must understand what is being done)
  • NEVER more than one blank line please!

C/C++

  • if/for should follow this:
    for(int i=0<i<n;i++)  A[i]=i;
    
    if(a==0) bool=true;
    
    if(a==0){
        output=true;
        c=b
    }
    else{
        output=false
        c=a;
    }
    
    for(int i=0<i<n;i++){
       A[i]=B[i];
       B[i]=0;
    }
    

Matlab

  • All matlab routines should start with a help (Example and See Also are not mandatory):
    function outputs=FunctionName(inputs)
    %FUNCTIONNAME - one line description
    %
    %   Extensive description of what is being done, inputs
    %   outputs, etc...
    %
    %   Usage:
    %      outputs=FunctionName(inputs)
    %
    %   Example:
    %      md.test=FunctionName(1);
    %
    %   See Also:
    %      FunctionName2, FunctionName3, ...
    

Variable/Enum/Functions Names

  • variables should not use capital letters. Use underscores to make variables more understandable.
  • Function names and enums should not use any underscore. Use capital letters to make names more understandable.

Example:

  Input* vx_input=GetInput(inputs,VxInput);
  • Functions that return an output corresponding to a given input should be named as follows:

Never ever Id2Name or IdAsName,... If necessary, "From" can be used instead of "To" if emphasis has to be put on the input:

Note: See TracWiki for help on using the wiki.