Original Copy 006 - Tracer Code
While working my way through The Pragmatic Programmer, I came across an interesting analogy. I want to share it with you.
Tracer bullets
Tracer bullets are projectiles shaped like regular bullets but are built with a pyrotechnic charge. Loaded at intervals throughout an ammo magazine, their charge ignites phosphorus when fired. This creates a visible trail, giving the shooter immediate feedback to adjust their aim accordingly.
The book pits this method against a more sophisticated approach: using computers to calculate every possible variable that might affect the aim of the shooter. These calculations are expensive and time consuming, but the hopeful result is more accuracy. Which is the better method?
To quote the book:
Not surprisingly, tracer bullets are preferred to the labor of calculation. The feedback is immediate, and because they operate in the same environment as the real ammunition, external effects are minimized. (p. 48)
This is a good analogy for software development. Consider a project that has a great deal of unknowns:
- You still haven’t fleshed out what the end product will look like.
- You’re working with new, unfamiliar technology.
- Because of the time it will take to complete, the environment of the project may shift.
These variables affect your project like wind speed, elevation and humidity affect the trajectory of a bullet.
What can you do to minimize these affects?
The solution proposed by the authors is to write tracer code.
Tracer code is an incremental development strategy that’s useful when you’re not certain where the project is headed. The requirements are still vague, and you want to involve the user in the development process.
Tracer code is light and flexible to change. It contains only the minimum viable functionality. If you notice that the project is off target, you adjust. Over time you will find the right trajectory.
I find this strategy to be really useful with side projects. Very often an idea will pop into my head, and instead of working out the crucial functionality, I’ll get lost in the details. It reminds me of this popular meme:
The concept of tracer code has resonated with me. The authors of the book say that it’s not the solution for every project, and I agree. But the underlying lesson is applicable everywhere:
Strive for simplicity.
On the blog
📝 My Commit Workflow
Over time I’ve refined my git commit
workflow. In this post I cover some of the tools I use in JavaScript projects to keep my commits clean and safe.
Seriously good stuff
📚 The Pragmatic Programmer
Not surprisingly, I’m recommending this book too! I’m only a third of the way through, but it’s very insightful so far. Some of the example code is difficult to digest, but the ideas in this book are timeless.
💻 RSCSS
Last week I listed Devhints, by Rico Sta. Cruz, in Seriously Good Stuff. This week I’m listing rscss
, another one of his projects. This isn’t a framework or a tool to use, but rather a system of ideas for how to structure your CSS. Now, I’m pretty comfortable with my CSS patterns, but I read through this and found some great tips to take away. There’s always something to learn!
📌 Region Folding in VSCode
A quick VSCode tip for you. With region folding you can add two comments around a section of code and “fold” it (minimize it):
I had no idea this one even a thing!
Talk to you next week,
Happy coding! 👾