Am am working on a small project for a USB device firmware.
I started from a working example, and am gradually adding new functionality and testing things. However, the new functionality is not all intended to be used in the final project. I am writing it to learn how to do things on this concrete platform, and fixing unexpected problems in the process (for example, on of my test PCs had non-functional USB ports).
What should I do with the old code? The code is version controlled, of course. I see two possibilities:
- Change old code into new one. An example here would be, when moving from having a Loopback over the UART (for testing purposes), and moving to more sensible use of the UART, change the DMA code to read not from the input of the UART, but from the CPU buffer, that is to be sent out.
- Use a bunch of
#if
statements to make the source code configurable, so that any version of the code can be compiled by only providing the correct#define
.
If the latter approach is recommended, where is the dividing line? I can't keep every line of code that I write, hiding it behind an #if
.