[sdiy] Resources on embedded programming good practices?

Ben Bradley ben.pi.bradley at gmail.com
Tue Apr 21 16:44:43 CEST 2020


I've been studying this in recent years and trying to catch up on the
"latest" (in the last couple of decades) programming methods and
technologies. Fortunately there's a good bit of stuff out there to
help write easier-to-read code with fewer bugs.

Coding standards are important, and the Barr Embedded C Coding
Standard (free in exchange for your email address) looks as good as
anything. I've picked up just about all of it for my code, and there
were some things I recognized I was already doing in an attempt to
make my code better. One thing in header files is always have the
preprocessor lines to prevent multiple header file inclusion.

There's a whole series of ideas that started off in the 1990s as
"agile" and "extreme programming" (XP, no relation to the MS Windows
version). There are books, blogs and online videos from various coding
conferences on topics such as Clean Code (among other things, limiting
the size of functions to keep them understandable, it's usually better
to have a large number of shorter functions) and Refactoring (changing
code to make it more understandable without changing its function.
Having especially good and appropriate names for functions and
variables is better than using "i, j, k" and comments describing
them).

Then there's C++, and virtually all C compilers thesedays also do C++.
Object orientation is the big advertised feature of C++, though
there's lots of other things as well. If you're doing anything with
dynamic memory allocation, putting the allocation and release in the
constructor and destructor methods of an object make for a better way
to avoid memory leaks as these are called automatically when an object
goes into and out of scope.

Then there's templates, and then there's the Standard Template Library
(STL), a mind blowing array of algorithms that grows with each new
iteration of the C++ standard.

On Tue, Apr 21, 2020 at 8:38 AM Spiros Makris <spirosmakris92 at gmail.com> wrote:
>
> Hello list,
> I  want to improve my coding habits so that my results will stay maintainable and easy to mod/reuse in the future. The scope of my applications (thus far) is sequencing and other similar low frequency control/real time devices. I use the arduino platform a lot for it's incredible simplicity and driver availability (I love you Teensy) but I'm trying to transition to STM32 eventually, seeing it as a more "serious" and professional platform. In both cases I use C/C++.
> I was officially taught C while studying in the university but that was 10 years ago and I've only picked up programming again in the past two or three. I understand digital hardware and the core C concepts, however, I don't have the opportunity to work alongside an experienced colleague to learn how I should write my code to be up to "industry standards" (= not be an unmaintainable mess etc) and I'm looking for something to refer to, other than my own trial and error.
> Example topics include anything from structuring headers to using globals or structuring function calls- especially under the prism of embedded applications. I would appreciate any suggestions on online resources or books.
>
> Regards,
> Spiros
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at synth-diy.org
> http://synth-diy.org/mailman/listinfo/synth-diy




More information about the Synth-diy mailing list