Editor's note:Norman Matloff is a professor of computer science at the University of California, Davis. He is teaching a course in the fall about ethics in tech. The opinions expressed in this commentary are solely those of the author.

(CNN) -- Leaders of the tech industry, long treated as national heroes, are looking a lot less heroic these days.

In case after case, we see tech titans and entrepreneurs misbehaving or breaking the law. They push the boundary of acceptable or ethical behavior that most of us have to play by. Even if some of them provide the technologies of tomorrow, it doesn't mean they can operate under different set of rules.

Norman Matloff

The biggest case to rock Silicon Valley in decades is a class-action lawsuit brought on behalf of former engineers against tech giants such as Google, Apple, Intel and Intuit. The leaders of these companies -- Apple's Steve Jobs, Google's Eric Schmidt and others -- are accused of conspiring to avoid poaching each other's engineers.

These executives didn't want to bid against each other for talent and risk disruption of projects caused by departure of key personnel. By secretly colluding to halt the labor competition, their companies got to keep the engineers and put a brake on their salaries.

Passenger planes nearly collide midair

The future of smartwatches

Google's plans for your wrist

The plaintiffs, who claimed heavy lost wages as a result -- about $9 billion for the estimated 100,000 engineers who were affected -- submitted as evidence damning e-mail messages, such as ones written by Schmidt that show he not only agreed to the plan but admonished others to not leave a paper trail. While Google's noble motto is "don't do evil," its corporate practice has at times failed to match what the company preaches.

In 2011, Google settled a multimillion dollar age discrimination suit brought by a former director, Brian Reid, who was 52 when he was fired. He had been subject to verbal slurs regarding his age, and data obtained during the legal discovery process suggested general ageist behavior by Google. (Disclosure: I served as an expert witness in that case.)

Then there's the issue of privacy.

Google has tried to get users to press Congress to support the company on the proposed Stop Online Piracy Act, which it opposed as going too far in combating copyright infringement. Schmidt's chilling 2010 comment, "We know where you are. We know where you've been. We can more or less know what you're thinking about," hasn't exactly inspired trust.

Facebook has repeatedly faced howls of protest over its privacy policies, and Zuckerberg didn't help matters with his feeble protestation that privacy is no longer a "social norm."

Joe Green, head of the immigration lobbying group FWD.us, which was founded by Zuckerberg, noted last year that the tech companies "... control massive distribution channels" that they could use to influence elections.

Harvard law professor Jonathan Zittrain described hypothetical scenarios in which this could be done surreptitiously, with both Facebook users and the public being unaware. Sounds creepy, doesn't it?

It's not all bad. Facebook declined to join the anti-poaching scheme, and Zuckerberg and his wife have given generously to California and New Jersey schools. And in 2010, Google withdrew from China rather than be complicit in China's Internet censorship -- an instance in which the company did live up to its noble motto.

Yet, there is no doubt that many tech leaders feel an almost messianic sense of entitlement. They consider their products as so beneficial to humanity that they act as though they are "boy kings."

Must we resign ourselves to these boy kings' shenanigans? What can we do?

For one thing, we should teach more ethics courses to people in tech. Engineering education has long included a component of ethics and social responsibility.

The Accreditation Board for Engineering Technology requires ethics instruction in all accredited university engineering curricula. The ABET code of ethics consists of tenets such as "serving with fidelity the public, their employers and clients," and cites lofty goals of "integrity, honor and dignity."

The stated principles for the Association for Computing Machinery, the main computer science professional body, are similar but more detailed, notably in including a section on information privacy.

Yet idealistic instruction in ethics may be undermined by the perceptions that one can't fight the system.

For example, there seems to be no plan to bring criminal charges against the anti-poaching colluders, even though federal judge Lucy Koh indicated she is still not happy with the proposed settlement for the engineers who experienced lost wages as a result of the secret wage-theft pact. And it is doubtful that a jury of libertarian Silicon Valley peers would vote to convict the tech bigwigs anyway.

Bars banning Google Glass

Is this 'Google Translate' for music?

Google unveils Android auto, TV and wear

Perhaps the most effective method of ethics enforcement is the old-fashioned one: Public shaming. When startup CEO Greg Gopman made insensitive, condescending remarks in reference to San Francisco's very visible homeless population, or when fellow entrepreneur Peter Shih made demeaning public remarks about women, public uproars made them both apologize.

And the recent revelation that Facebook experimented on nearly 700,000 users without their knowledge has sparked outrage over the company's ethics policy -- or lack thereof. The company blamed the incident on a rogue research team and said to take "a very hard look at this process."

We may have to give the tech boys some time, but hopefully they'll be smart enough to realize that codes of ethics are just as important as computer codes.