The Cobra Effect and Software

We like to focus on inputs, not outputs. Inputs are simple. Sugar for baking, metal for factories and petrol for cars. Software is no different.

But by focusing on inputs, we often encourage the dreaded cobra effect.

Basically, we incentivize bad behaviour.

For example, let's say we have metrics for a team to write 30 tests a sprint and maintain 90% code coverage.

On the surface, it sounds good! 90% coverage will mean our code is tested thoroughly and 30 tests a sprint means we definitely will be making the system more robust.

But, consider the other side of the coin.

What's the solution?

Focus on what you want the desired outcome to be and then design metrics that would change based on that outcome.

In the above example, rather than enforcing code coverage, we could measure the number of defects raised, the number of releases, and the number of failing test cases.

Metrics are important. But, consider the kinds of behaviour that those metrics will encourage. Otherwise, you'll need to watch out for the cobras.