it’s not always easy to see how wrong a couple of lines of code are, when you’ve been tasked with optimising the performance of a piece of software in a certain environment.
“Bend realty to your will”. You’re not a software developer, are you?
Mark Treveil

With respect to the original posting, this comment only really applies to the Volkswagen case (the others are a different kind of corporate crime, best addressed at the upper management level). There is, however, a totally unhealthy industry obsession with winning benchmarks, even when the benchmarks have absolutely no bearing on the real-world problem the software is supposed to address. I am not surprised that Volkswagen cheated on the EPA tests, nor do I blame the developers of that code for it.

I can imagine the way it came about: A developer and her manager are sitting at lunch. Developer says, “I am frustrated that we can’t get this engine to run clean, maybe we should just tweak it to pass the EPA tests [I’m kidding, can’t you see I am kidding? please tell me you know I am kidding!].” Manager goes home and wakes up in the middle of the night thinking, “that’s brilliant. I am going to pass that to my manager.” A task force is formed to determine how to tweak the code (the originator of the idea is left out of the loop). Two weeks later, specs come from somewhere saying that the engine is performing poorly under certain environmental conditions and the following adjustments need to be made. Some other developer dutifully makes the “improvements”, and voilà, the engine passes the EPA tests.

I have spent my career pushing back on meaningless tweaks to code to meet benchmarks. I have, for the most part, worked for people who saw value in my pushing back. Usually, the compromise is to address the benchmark problem by squeezing better overall performance from the code, but the competition is always out there waiting for a chance to claim superiority because they can get an extra 0.01% out of a benchmark that demonstrates no real-world value to anyone. In the end, code is no different from any other aspect of business: it can be done right or it can cut corners for a quick profit. It is the choice of the corporate leadership which approach wins in a given company.