One of the continuing lessons of my personal and professional life has been learning every day a bit more about the intent/effect gap.
There’s what I think I’m saying, and there’s what my child hears. Two very different things.
There’s what I think I told the software to do, and there’s the code I wrote. Also two very different things!
Perhaps writing software can help us to be honest about how terrible we are at communication?
One of my core competencies is creating race conditions. As a web developer, I write code that reacts to events. A user clicks on a mouse, something happens. New data comes from the server, something else happens. We use wonderful test automation software called Cypress which uses our application and fills out forms, clicks on buttons, etc… Like all software, it does exactly what I ask it to do.
The software that Cypress tests is also code I wrote. Like all software, it does exactly what I ask it to do.
Most days, I look at an error that Cypress found in code that does exactly what I told it to do and wonder: how the heck could this happen. I have to slow down, figure out what I asked the code to do, and how that created an error condition. Just as double entry accounting forces us to match the credits and the debits, code with tests forces me to write down what I’m doing twice: first, I ask the code to do something. Then, I write a test to check that it does what I think it should. (Where practical, I’m working on getting in the habit of writing the test first).
This morning, I wrote some code that waited two seconds before writing information to the server (We don’t need to save every character a user writes back to the server). Then, I wrote a Cypress test that tried edit a form as fast as possible. So the test data Cypress created wasn’t being saved. 💥
The application and test software did exactly what I asked them to do, and yet I was surprised by the error. My mental model was out of sync with the instructions I’d given the software. The intent/effect gap, clear as day, and no opportunity to blame the software for not listening carefully, or failing to read my mind.
They say we can learn something new every day. I find that I’m also very good at re-learning something I already kind-of-knew. Perhaps it will even help me to be more mindful of the intent/effect gap when I speak with my children and other humans!