Extreme Programming with microcontrollers
Intro
I use the Extreme Programming (XP) / Agile software development methodology. One of its advantages is that by using understandable memberfuctions and variables, only few comments are required. The code is readable from itself. Another aspect is that classes and memberfunctions should be independent testable. We can even use Extreme Programming at the Arduino microcontroller. Because we use inline functions, no additional machine code will be generated.
Here is a c++ codefragment of my Solar cell curvetracer:
int CurveTracer::trace(bool printCurve, int _averaging, int stepTime_ms) for(int i=0; i<=1023; i++) |
The software is split down in many memberfunctions, as you can see. Altough some memberfunctions are very short, they are still written as memberfunctions. Look at the function calcPower:
void inline CurveTracer::calcPower(int mV, int mA, int &mW, int &mWpeak) |
Here is the function call. It is not necessary to use comments because the code explains itself:
calcPower(mV, mA, mW, mWpeak); |