02.03.2014 Views

Tornado

Tornado

Tornado

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Tornado</strong> 2.0<br />

User’s Guide<br />

■<br />

Comments on global variables appear on the same line as the variable<br />

declaration, using the semicolon (;) character:<br />

set day night ;# This is a global variable<br />

B.3.6 Naming Conventions<br />

The following conventions define the standards for naming modules, routines and<br />

variables. The purpose of these conventions is uniformity and readability of code.<br />

■<br />

■<br />

■<br />

■<br />

When creating names, remember that code is written once but read many<br />

times. Make names meaningful and readable. Avoid obscure abbreviations.<br />

Names of routines and variables are composed of upper- and lowercase<br />

characters and no underbars. Capitalize each “word” except the first:<br />

aVariableName<br />

Every module has a short prefix (two to five characters). The prefix is attached<br />

to the module name and to all externally available procedures and variables.<br />

(Names that are not available externally need not follow this convention.)<br />

fooLib.tcl<br />

fooObjFind<br />

fooCount<br />

Names of procedures follow the module-noun-verb rule. Start the procedure<br />

name with the module prefix, followed by the noun or object that the<br />

procedure manipulates. Conclude the name with the verb or action that the<br />

procedure performs:<br />

fooObjFind<br />

sysNvRamGet<br />

taskInfoGet<br />

module name<br />

procedure name<br />

variable name<br />

foo - object - find<br />

system - non volatile RAM - get<br />

task - info - get<br />

B.3.7 Tcl Style<br />

The following conventions define additional standards of programming style:<br />

■<br />

■<br />

■<br />

Comments: Insufficiently commented code is unacceptable.<br />

Procedure Length: Procedures should have a reasonably small number of<br />

lines, less than 50 if possible.<br />

Case Statement: Do not use the case keyword. Use switch instead.<br />

334

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!