This guide was written in 2014. As in all things, time evolves how things are done. In 2024 and beyond, you may find a couple differences. There are many resources for writing good code in books and the internet. It is suggested that the reader make their own choice as to which references work best.
With the rise of artificial intelligence tools, it is entirely possible that any code produced by such tools is incorrect or follows conventions not used in other parts of a project. It is suggested that the programmer have basic knowledge of best practices to spot potential issues.
Any code we write at Adafruit is 'read' by a many thousands of people with varying levels of experience with the software and hardware they are working with.
That puts a unique burden on us to produce code that doesn't just 'work', but is also easy to understand and maintain.
In a conscious effort to improve our own code in this area, we've put together this simple guide to writing code that's easier to read, maintain and understand.
While everything suggested here is somewhat personal, and largely a reflection of my own habits working in C over the years, as Adafruit continues to grow as a company we want to put more emphasis on code quality, in the same way we've focused on the quality of our HW designs and tutorials.
We've tried to keep these guidelines as general as possible recognizing that everyone has (and has the right to) their own style, but there are some things we think are worth insisting on in the interest of readability and keeping things accessible for customers.
Text editor powered by tinymce.