Uh, I always forget...
Here is:
Sorry for the long post, there was no way around
Example files:
Example h that is conform with suggested standard:
http://home.nith.no/~breale/Arduino/LEDClass/LED_Reform01.h
Example cpp that is conform with suggested standard:
http://home.nith.no/~breale/Arduino/LEDClass/LED_Reform01.cpp
Example pde that is conform with suggested standard:
http://home.nith.no/~breale/Arduino/LEDClass/examples/Blink/Blink.pde
Reform description:
http://home.nith.no/~breale/Arduino/Reform_v0.1/
Naming of Classes and Functions:
Classes are prefixed C
Abstract Classes are prefixed AC
Class names start upper case after prefix
Functions start lower case
Variable Protocol:
DATATYPE SELECTION
Always use the variable type that uses the least amount of RAM but has appropriate min / max values.
Always use const when suitable
If the bit-width is crucial use a typedef 'typedef uint8_t my8bit'or a 'struct MyThreeBitDatatype { unsigned char : 3; };'
VARIABLE NAMING:
Private member variables start with underscore
Variable names start with prefixes that indicate datatype [after the member underscore]
-bool b bVariable
-char c cVariable
-byte by byVariable
-int i iVariable
-unsigned int ui uiVariable
-long l lVariable
-unsigned long ul ulVariable
-float f fVariable
-double d dVariable
-struct st stVariable
-enum e eVariable
arrays should be prefixed by datatype prefix followed by a
-short[] saVariables; //public string array
Object instances should be prefixed o
Object instance variable names should also describe the originated class
-Shape _oShape; //private object of class Shape
Pointers should be prefixed by datatype prefix followed by p
-int* _ipVariable; //private int pointer
Control Structures:
===============================================
if ( condition )
{
execute1();
}
else if ( condition )
{
execute2();
}
else
{
execute3();
}
while ( condition )
{
execute();
}
do
{
execute();
}
while ( condition );
for ( initialization; contition; modify; )
{
execute();
}
This following syntax might seem a bit wierd
But it is to ensure that any variables initiated
in a case block gets destructed before the break.
switch ( expression )
{
case condition1:
{
execute1();
}
break;
case condition2:
{
execute2();
}
break;
case condition3:
case condition4:
{
execute4();
}
break;
}
Code Protocol:
//Name according to 'Variable protocol:'
//Always initiate to a default value
//Exception is inside for loops, where variablenames like x,y,z,i,j,k,l is accepted
//Curly brackets always 'triggers' a line feed.
//Paranthesis has whitespace on both insides [i.e ( condition )]
//C++ Keywords see 'Control Structures'
if ( condition )
{
execute;
}
//Space after keywords
//Functions:
//Name according to 'Naming of classes and functions:'
returntype functionName( parameter:datatype parameter:name )
{
return returntype;
}
Funcion names does not get followed by a whitespace as keywords do
Descriptions and Comments:
http://home.nith.no/~breale/Arduino/Reform_v0.1/DescriptionsComments.txt
Default files with descriptions:
Default cpp that is conform with suggested standard:
http://home.nith.no/~breale/Arduino/Reform_v0.1/default.cpp
Default h that is conform with suggested standard:
http://home.nith.no/~breale/Arduino/Reform_v0.1/default.h
Default pde that is conform with suggested standard:
http://home.nith.no/~breale/Arduino/Reform_v0.1/default.pde
Thougts, questions and disagreements are very welcome!