Difference between revisions of "CodeStyleGuide"

From aHuman Wiki
Jump to: navigation, search
(Automated page entry using MWPush.pl)
 
(Automated page entry using MWPush.pl)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
 
<pre style="color: green">Coding Style Guide</pre>
 
<pre style="color: green">Coding Style Guide</pre>
 
@@[[Home]] -> [[CodeStyleGuide]]
 
@@[[Home]] -> [[CodeStyleGuide]]
  
  
http://ahuman.googlecode.com/svn/images/wiki/procedures/codestyle.jpg
+
http://usvn.ahuman.org/svn/ahwiki/images/wiki/procedures/codestyle.jpg
 
----
 
----
  

Latest revision as of 19:05, 28 November 2018

Coding Style Guide

@@Home -> CodeStyleGuide


codestyle.jpg


What is The Code Style and Why We Need It

  • Code style is the only way to share code
  • Good code style helps to develop complex programs

Naming Convention

  • use http://en.wikipedia.org/wiki/CamelCase as a direction
  • name variables, functions as __varName__, __doSelfDescriptiveAction__
  • name classes, typedefs, enums, structs as __!TypeName__
  • name constants, defines, as __MAXNAME__
  • name files in lower case, as __filename.h__
   # name headers by functional area, as __aidb.h__
   # name source files by class, use one file per class, as __nnlayer.cpp__

Formatting

  • align function body with 8-char tabs
  • use spaces to delimit any text, except function name, from brackets and commas
  • use spaces before and after '='
  • use empty lines to delimit closely related groups of code lines (code block)
  • use the doxygen style function header comments.

Comments

  • use one-line comments for every code block
  • try write comments in such way that they represent sequential specification of function if delete the code
  • use area delimiter to split file into groups of functions of very different matter - e.g. header references, interface functions, internal implementation functions, standard interface implementation, such as Object