Writing code for products is different from writing code for yourself.

And that is differrent again from writing code for other developers (eg: open source).

Differences between coding styles explained

There are three types of code. I am going to attempt to differentiate between the different approaches by showing an example based on ESP8266 here.

1. Coding for yourself

This type of code is the easiest to do of course but comes with it’s own pitfalls and requirements. I would say that a git repository and README is a minimum requirement for any project, even if it’s just a test to see if something works. I have been guilty of ignoring this and later coming back to a project to find I have no idea of what it is about, or even how long I worked on it and even whether it worked or not.

2. Coding for a product

Now one needs to take into account the potential users of the product. For example ESP8266 WiFi connection now needs a web interface to input the password. A manual is also needed to explain how to use the product. The coding style can remain the same (although for all coding I recommend at least describing the various functions in the code)

3. Coding for other developers

If your code is going to be read and extended by other developers, other considerations come to the fore. Documentation, reproducible tests and linting are important, as well as a README which explains what the code if for as well as how to run it. For ESP8266 Arduino IDE is no longer good enough, as it doesn’t have the means to specify library versions – which one reason I have moved over to using PlatformIO almost exclusively for coding (that and code highlighting and navigation with VSCode)

Conclusion

So there you have it – a quick rundown and not very complete but hopefully you get the idea. The requirements for Open Source development are pretty exacting – something that has taken me a long time to realise, and am still working on perfecting in my own code.

Leave a Reply

Your email address will not be published. Required fields are marked *