root/library/doc/html/codingrules.html @ 616

Revision 616, 6.8 kB (checked in by smidl, 15 years ago)

doc, sorted related pages

Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<title>mixpp: Coding Rules (Mostly inherited from IT++)</title>
6<link href="tabs.css" rel="stylesheet" type="text/css"/>
7<link href="doxygen.css" rel="stylesheet" type="text/css"/>
8</head>
9<body>
10<!-- Generated by Doxygen 1.6.1 -->
11<script type="text/javascript">
12<!--
13function changeDisplayState (e){
14  var num=this.id.replace(/[^[0-9]/g,'');
15  var button=this.firstChild;
16  var sectionDiv=document.getElementById('dynsection'+num);
17  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
18    sectionDiv.style.display='block';
19    button.src='open.gif';
20  }else{
21    sectionDiv.style.display='none';
22    button.src='closed.gif';
23  }
24}
25function initDynSections(){
26  var divs=document.getElementsByTagName('div');
27  var sectionCounter=1;
28  for(var i=0;i<divs.length-1;i++){
29    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
30      var header=divs[i];
31      var section=divs[i+1];
32      var button=header.firstChild;
33      if (button!='IMG'){
34        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
35        button=document.createElement('img');
36        divs[i].insertBefore(button,divs[i].firstChild);
37      }
38      header.style.cursor='pointer';
39      header.onclick=changeDisplayState;
40      header.id='dynheader'+sectionCounter;
41      button.src='closed.gif';
42      section.id='dynsection'+sectionCounter;
43      section.style.display='none';
44      section.style.marginLeft='14px';
45      sectionCounter++;
46    }
47  }
48}
49window.onload = initDynSections;
50-->
51</script>
52<div class="navigation" id="top">
53  <div class="tabs">
54    <ul>
55      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
56      <li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
57      <li><a href="annotated.html"><span>Classes</span></a></li>
58      <li><a href="files.html"><span>Files</span></a></li>
59    </ul>
60  </div>
61  <div class="navpath"><a class="el" href="dev_guide2.html">Howto Contribute to BDM - Advanced development</a>
62  </div>
63</div>
64<div class="contents">
65
66
67<h1><a class="anchor" id="codingrules">Coding Rules (Mostly inherited from IT++) </a></h1><p>In the following sections we describe the naming conventions which are used for files, classes, structures, local variables, and global variables.</p>
68<h2><a class="anchor" id="cr_variables">
69Default Naming Rules for Variables</a></h2>
70<p>Generally, variables are named using lower-case letters and words are separated using under-score. But there are many exceptions, for instance abbreviations or classical matematical notations. Therefore, coding rules for variables are quite free. Examples:</p>
71<ul>
72<li>
73<code>`FFT_size'</code>  </li>
74<li>
75<code>`initial_RV'</code>  </li>
76<li>
77<code>`my_variable'</code>  </li>
78</ul>
79<h2><a class="anchor" id="cr_files">
80Default Naming Rules for Files</a></h2>
81<p>Files are named using lower-case letters and words are separated using under-score. If an abbreviation is inevitable within file name, it is written with lower-case letters.</p>
82<p>Source files are named using <code>`.cpp'</code> suffix, whereas header files end with <code>`.h'</code> extension. Examples:</p>
83<ul>
84<li>
85<code>`my_file.h'</code>  </li>
86<li>
87<code>`user_info.cpp'</code>  </li>
88</ul>
89<h2><a class="anchor" id="cr_file_templates">
90Form of the source files</a></h2>
91<p>For all the library classes, both header file `[filename].h' and source file `[filename].cpp' should be implemented. And the following few rules should be respected</p>
92<ul>
93<li>
94<p class="startli">if possible, each `#include ... ' dircetive should be located within the `.h' file, one obvious exception is the case of `#include "[filename].h"' written in `[filename].cpp' </p>
95<p class="endli"></p>
96</li>
97<li>
98<p class="startli">firstly, system headers should be included (i.e. those with brackets `#include &lt;system_header_name&gt;'), other headers (like `#include "my_header_name.h"') should follow (this rule leads to the faster search of an error on some compilators) </p>
99<p class="endli"></p>
100</li>
101<li>
102<p class="startli">source code itself should be placed in the `.cpp' file, `.h' should contains only class declarations and documentation (this rule has a few exceptions like inline functions, templates and some extremely short function bodies)</p>
103<p class="endli"></p>
104</li>
105</ul>
106<p>Rules considering formatting of the source code itself are stored in the file /system/astylerc, which is a configuration file for code formating utility named ASTYLE. To apply them, download the proper version from its web page <a href="http://astyle.sourceforge.net/">http://astyle.sourceforge.net/</a></p>
107<h2><a class="anchor" id="cr_functions">
108Default Naming Rules for Functions</a></h2>
109<p>Function names are named using lower-case letters and words are separated using under-score. Abbreviations, when used in function names, are also written with lower-case letters. This rule applies both to stand-alone functions as well as to member functions of classes. Example:</p>
110<ul>
111<li>
112<code>int my_function_name(int a, int b)</code>  </li>
113</ul>
114<h2><a class="anchor" id="cr_specialfunctions">
115Convention for sensitive functions</a></h2>
116<p>For efficiency, some functions may return pointers to internal variables. Such functionality is indicated by underscore as the first letter in the the name.</p>
117<ul>
118<li>
119<code>mat* _internal_matrix()</code>  </li>
120</ul>
121<h2><a class="anchor" id="cr_classes">
122Default Naming Rules for Classes and Structures</a></h2>
123<p>Each new word in a class or structure name should always start with a capital letter and the words should not be separated. Abbreviations are written with capital letters. Examples:</p>
124<ul>
125<li>
126<code>`MyClassName'</code>  </li>
127<li>
128<code>`MyStructName'</code>  </li>
129<li>
130<code>`OFDM'</code>  </li>
131</ul>
132<h2><a class="anchor" id="cr_classes_functionality">
133Default Functionality of Classes</a></h2>
134<p>All classes that are configured by input parameters should include:</p>
135<ul>
136<li>
137default empty constructor  </li>
138<li>
139one or more additional constructor(s) that takes input parameters and initializes the class instance  </li>
140<li>
141setup function, preferably named <code>`setup'</code> or <code>`set_parameters'</code>  </li>
142</ul>
143<p>Explicit destructor functions are not required, unless they are needed. It shall not be possible to use any of the other member functions unless the class has been properly initiated with the input parameters. </p>
144</div>
145<hr size="1"/><address style="text-align: right;"><small>Generated on Sun Sep 13 23:08:55 2009 for mixpp by&nbsp;
146<a href="http://www.doxygen.org/index.html">
147<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
148</body>
149</html>
Note: See TracBrowser for help on using the browser.