Mindsets that will improve your life as a software developer

Martin Stabenfeldt
Martin Stabenfeldt | 3 February, 2020

When distilled, it often sums down to these two statements:

  1. "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Code for readability.." -- John F. Woods
  2. People make mistakes. 

 
Before submitting your pull request, read through your code and think – Have I written a readable code that the next guy will be happy to work with? Or will he be having difficulties understanding what the code actually does? How easy will it be to make modifications? Do we have tests that verify that the code works as intended?

 

1. Code responsibly

Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.

 

2. People make mistakes


You might run your script in the wrong environment, causing the production databases to be flushed in a split second. Make sure you build the system in a way that doesn’t allow this to happen. Who hasn’t executed a task you thought would mutate data in your development environment, but actually mutates production data? You learn by your mistakes and the next time you write a script that mutates data, you add an extra check that verifies that you’re not running the command in the production environment.

A skilled developer would verify himself that he runs the script in the correct environment, you might say? Well, history shows that even the most skilled people make mistakes. Astronauts, a group of highly skilled and focused people, they of all people wouldn’t press the wrong button during a mission, would they? Turns out they too make mistakes.

Margaret Hamilton, working on the Apollo program brought her daughter Lauren to work one day. Lauren went exploring and caused a “mission” to crash by launching the prelaunch program, P01. By selecting the prelaunch program P01 during a mission, one would be in deep shit as it wipes out navigation data and the computer was not equipped to pilot the craft with no navigation data. Knowing that selecting P01 during a mission would cause it to fail, Margaret suggested they made a change to the system so that it would not be possible to start P01 during flight. Her bosses said that would not be necessary, as astronauts are trained to not make any mistakes.

Margaret’s suggestion was only considered unnecessary until the next mission with Apollo 8. With 4 astronauts on board, Jim Lovell selected the P01 program by mistake. As Margaret’s suggestion was deemed unnecessary they had no safeguard and the navigation data was wiped out. Luckily Margaret had updated the documentation to describe how one could upload new navigation data. Meaning they would be able to get back to earth after all.

 

Margaret Hamilton inside a mock-up of the Apollo command module. Photo by MIT

Knowing that people can and will make mistakes is something you should be conscious of. They might drop the production database or start a service by mistake. Do you have backups of your databases and do you monitor which ports that listen to incoming traffic?

Have you ever thought to yourself - “This is dangerous ground? If my colleague doesn’t pay attention here, he might bring the system down.”? If you develop a system or a program you know will behave in an undesired way if one doesn’t pay really good attention, then you’re designing it wrong! People make mistakes and you should design your systems in a way that doesn’t allow human errors to bring the system down.

Not only will your colleagues be grateful if you follow these pieces of advice, but your future self will also thank you! 

 

Topics

app development development Advice