Thursday, January 12, 2017

The Three Laws of Automation

A version of the following blog article was posted on Vertafore Voices, an internal company blog for employees to share perspectives.

I am not a fan ​of self-driving cars.
That may seem like a surprising statement coming from me.
I have spent most of my software engineering career working on automation. Automated builds, deployments, tests, and even infrastructure, you name it, I have found ways to make software drive itself without human intervention.
I believe that automation is a good thing that can make our lives better. But not all automation is practical or desirable.
Science fiction fans may remember Isaac Asimov's Three Laws of Robotics from his Robot series of novels:
  1. 1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.
  2. 2. A robot must obey the orders given it by human beings except where such orders would conflict with the First Law.
  3. 3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws
When I consider whether or not to automate a task, I look at three simple rules. Inspired by Asimov's list, I call them the Three Laws of Automation:
  1. 1. A human shall not automate a task that happens infrequently
  2. 2. A human shall not automate a task that is not well defined
  3. 3. A human shall not automate a task that requires creativity
These simple rules go a long way in helping me to determine if automation is worth doing. To see how they apply, let's look at a task that automation is frequently applied to: testing software.
Automated testing happens frequently. Ideally every test case is run every time the software is built, potentially multiple times per day. In practice, developers have unit tests which run very fast every time the software is built, and system tests which run less frequently, say once a day,  because they take longer to run on limited hardware. Still, software testing satisfies Law 1.
Software testing is well defined. A well-written test case is a series of action steps followed by a verification step. Did the expected result occur, Yes or No? If Yes, the test case Passed. If No, the test case Failed. Software testing satisfies Law 2.
Running software test cases manually requires no creativity.  It is repetitive and mindless. Most software testers dislike that part of their job, and are happy to hand that over to a machine. Other parts of the software tester's job, such as test design, interpreting test results, and troubleshooting failures, are creative activities. They require intelligence, imagination, and insight. Automating those tasks is possible, but is much harder, and tools that automated those tasks are not widely adopted, for the simple reason that people enjoy doing creative tasks. 
In any case, running software tests satisfies Law 3. Since all Three Laws of Automation are satisfied, it makes sense to automate software testing.​
There are many other examples in daily life where what was once a manual task has been automated during our lifetimes. Here are just a few: maps, filing personal income taxes, buying airplane tickets. You can probably think of many others. In each case the Three Laws of Automation apply.

How about those self-driv​​ing cars?
Law 1 certainly applies to cars. Driving is a frequent task that most of us have to do every day.
What about Law 2? Is driving well defined? Not even close.
Consider what makes for a successful taxi or rideshare passenger experience. Being a good driver is about much more than being able to deliver your passengers quickly, to the right location, without getting pulled over by the police, or without injuring or killing anyone or damaging property. Typically they involve local knowledge, friendliness, confidence, and many other things that cannot be described to a computer. And this has to be done while traveling together with other drivers and pedestrians who may or may not behave rationally.
We could stop here, but what about the Third Law of Automation? Is driving creative? Absolutely.
Driving can feel routine and monotonous most of the time. But that is an illusion. Routine driving is not stable. It can become emergency driving in a fraction of a second, at any time.
One day my wife was driving our family back from a road trip. Traffic on the highway was light, weather was good, and the situation was so routine that I was able to nap in the front passenger seat.
Suddenly a large tire came loose from a truck going the opposite direction on the highway. It bounced towards our car at over a hundred miles an hour. My wife instantly realized that she needed to speed up rather than slow down to avoid it. Because of her quick thinking, the tire bounced just behind our car by inches and rolled harmlessly to the side of the road. We made our way home safely with a great story to share but none the worse for the experience. If not for my wife's counter-intuitive reaction, we would have been in a major accident.
I don't know how to describe such a situation to a computer. I don't believe that anyone does. I could say the same about much less extreme situations that happen in driving every day.
For me, cars are a bad candidate for automation, at least at the present state of technology. We would need something very close to Asimov's imaginary robots, with their powerful sensors, ability to think creatively, and hyper focus on the fragility and sanctity of human life, for self-driving cars to be safe.
Self-driving cars also feel to me like an attempt to automate the technology of today rather than the technology of tomorrow.
Consider how the car replaced the horse in personal transportation. Though we speak of horsepower, a car is nothing like a horse. A mechanical horse powered by an internal combustion engine would be a monstrosity. That is probably why such a thing was never built. A car is so much simpler.
We should be asking the question: How do we automate the movement of people? There may be answers to that question that are completely different from, and much simpler than, a self-driving car.
Software automation can be like that too. Instead of automating what you are currently doing by hand, ask yourself if the task could be done in a completely different way that would be easier to automate. The Three Laws of Automation can be helpful in checking if you are on the right track.

No comments: