Perhaps Petraeus and his former colleague Gen. John Allen were addicted to e-mails on some level, but in jobs like theirs, sloppiness can be fatal. In the digital age where everything seems to have a trail, there is really no escape, no appeal and no cover-up.

There's been a lot of talk from Petraeus' supporters that he did the honorable thing by quitting. The truth is, given his job and the digital world we live in, he had no choice.

William Doyle is author of "A Soldier's Dream: Captain Travis Patriquin and the Awakening of Iraq" (Penguin) and co-author of "A Mission from God: A Memoir and Challenge for America" (Simon & Schuster).

Noel M. Tichy and Chris DeRose: Resignation was honorable, necessary

David Petraeus is by equal account an honorable man, a great patriot and one of the most important generals in recent U.S. history. So was it really necessary for our country to lose one of its brightest intellects in the top spy job just because he had an affair? Can't you hear the laughter coming from France or Italy, where the reaction to discovery of a mistress or even a child out of wedlock is blasé?

Petraeus' resignation was as honorable as it was necessary. He didn't lose his job over infidelity. He had to either resign or be fired because he exercised poor judgment. It's that simple.

Petraeus' surreptitious extramarital affair was investigated for fear he might have been the target of blackmail or revealed national secrets. As a long-time Washington insider, Petraeus was no naif about the consequences if the affair became public.

The moment the man in charge of the world's most powerful spy agency engaged in the affair, he took a risk that had repercussions well beyond his personal life. His self-indulgence invited an inevitable media circus that has undermined his credibility and distracted his organization at the critical moment it faces an inquiry into the September attack on the U.S. Consulate in Benghazi, Libya.

Petraeus knew that his ability to stand tall before his co-workers at the CIA, the Congress or the American people had been compromised. To enable the CIA to get on with its business, he accepted the need to step aside so that his personal life didn't become the focus.

Organizations are built on trust and shared values. When leaders exercise bad judgment and take actions that risk the well-being of their constituents -- even if it happens in their personal life and is not criminal -- they compromise that trust and have to go.

In the business world, CEOs or top leaders at Best Buy, Stryker, Highmark and Lockheed Martin have lost their jobs in recent months because of sexual affairs. Most companies have explicit rules or require disclosure of relationships within a company. These policies are to protect employees from managers who might leverage their power to sexually harass subordinates or engage in favoritism, creating intolerable work environments. Such rules apply to all employees, but these business leaders failed to acknowledge their affairs. Some simply kept secrets from their boards of directors, while others took deliberate steps to conceal them, no doubt to protect their reputations and marriages.

To Petraeus' credit, he reportedly never asked for special treatment and knew that public knowledge of his lapse in judgment would inevitably lead to his removal. Let's applaud Petraeus and thank him for his invaluable service to our country.

As Americans, we seem to love redemption stories and have been so often willing to give our leaders a second chance after they demonstrate their fallibility. Petraeus will no doubt resurface in coming years and, we hope, continue to contribute to our nation's welfare. It just won't be at the CIA.

Noel M. Tichy and Chris DeRose are co-authors of "Judgment on the Front Line: How Smart Companies Win By Trusting Their People." The have advised CEOs around the world and worked with Royal Dutch/Shell, Ford Motor Company, 3M and HP.

Follow us on Twitter @CNNOpinion.

Join us on Facebook/CNNOpinion.