What if? Perpetual question cycles of responsible developers

We all love it when a plan comes together, yet let’s face it, 💩 happens…
And we cannot decently just ignore it and turn a blind eye.
Hopefully we thought about edge cases upfront…
I’m holding two Master of Sciences in acoustics and applied maths and have served as a Navy officer before working as a web developer. All these environments are very different but they have some patterns in common.
Whilst studying maths, you get used to reason about equations. When you turn to physics, these equations have a physical meaning. So whenever you model something with: 1/(x - 1), one of the first questions you face is: “What if x = 1?”. Indeed you cannot divide by 0.
Studies and then work let us confront with potential problems. It is part of our duty, as conscientious professionals to identify and address them in the best possible way.
Back in the Navy, when you are in charge of the navigation, part of the job is to wonder “What if I have a man at sea right now?”. Indeed it is a critical situation: you have to maneuver fast and the environment matters a lot: direction of the wind etc…
During our different briefings everybody was told what to do. But one of the most important parts of it was to think about what to do in case something wrong happens. I particularly remember an intensive session with commandos for whom “What if?” is a matter of life and death.
Anticipation, thinking, we are paid to bring added value and part of it is definitely to think about what can go wrong. We cannot tackle every single potential problem and we do not want to enter paranoïa. But it’s comfortable to have a parachute or an airbag in case of emergency. And to get it you must think about it.
As web developers the same “What if?” cycle of questions applies:
- you are saving two objects in database? What if the second save fails? You most likely need a database transaction
- you are making database queries? What if you get malicious input from the user? You most likely need to sanitise user inputs
- you create an object in an external api and need to save the reference inside your own database? What if your database insert fails?
I am currently writing a programming book for Ruby developers that will address and discuss these questions.
It is our duty as professionals to think beyond the happy path where everything works as expected. We have to handle errors properly, responsibly. Yet we do not want to enter defensive programming madness.
This is all about balance, and I intend to provide you with the best advice. Stay in touch, I hope the book would be finished within the end of this year.
