D. Topics in Computer Science · Topics in Computer Science: Sustainability, Ethics, Emerging Technologies and CareersCodes of Ethics for Computing Professionals: ACM, IEEE and Beyond
D2.2About 70 minutes
Learning goals- I can explain why computing professionals need a code of ethics, using examples such as plagiarism, backdoors, viruses, spyware and logic bombs.
- I can describe the structure and key principles of the ACM and IEEE codes and the Software Engineering Code of Ethics.
- I can identify the essential elements shared by codes of ethics and apply them to a workplace scenario.
- I can explain how a structural code-similarity checker works and its limits.
Words to know
code of ethics
A public statement of the duties and standards a profession's members accept.
backdoor
A hidden way to bypass a system's normal authentication or security.
logic bomb
Code that performs a harmful action when a condition, such as a date or event, is met.
spyware
Software that secretly gathers information about a user or device.
virus
Malicious code that copies itself into other files or programs and spreads.
Jaccard similarity
The size of the intersection of two sets divided by the size of their union.
whistle-blowing
Reporting wrongdoing inside an organization to people who can act on it.
Power needs rules
Programmers build systems that run hospitals, banks, cars, elections and schools. A small decision in the code, such as how carefully input is checked or whether a hidden password is left in, can affect millions of people who will never see the code. Professions with this kind of power, such as medicine, law and engineering, write codes of ethics: public statements of the duties their members accept.
Expectation D2.2 asks you to describe the essential elements of a code of ethics for computer programmers, using the ACM and IEEE codes as examples, and to explain why such codes are needed.
Why codes are needed: what can go wrong
- Plagiarism: copying others' code or ideas without credit (see Intellectual Property).
- Backdoors: hidden ways into a system that bypass normal security, sometimes left "for testing" and later found by attackers.
- Viruses and other self-spreading malware.
- Spyware: software that secretly collects information about users.
- Logic bombs: code that does damage when a condition is met, such as a date or a programmer's account being deleted.
- Deceptive software: in 2015 Volkswagen admitted that software in millions of its diesel cars detected when the car was being tested for emissions and changed how the engine ran so it passed, while emitting far more pollution on the road. Engineers wrote that code.
- Unsafe software: in the 1980s, software errors in the Therac-25 radiation therapy machine contributed to patients receiving massive radiation overdoses. The case is still taught as a lesson about testing, honest reporting of problems and safety-critical design.
Laws forbid some of these, but not all, and laws can't anticipate every situation. A code of ethics guides professionals in grey areas and tells the public what to expect.
Four kinds of malicious or deceptive code named in the curriculum. Each one abuses the trust users place in programmers.The ACM Code of Ethics and Professional Conduct
The Association for Computing Machinery (ACM), one of the largest computing societies in the world, updated its code in 2018. It has four sections and 25 principles (7 + 9 + 7 + 2), each with guidance:
- General ethical principles, such as 1.1 contribute to society and to human well-being, 1.2 avoid harm, 1.3 be honest and trustworthy, 1.4 be fair and take action not to discriminate, 1.5 respect the work required to produce new ideas and creative works, 1.6 respect privacy, 1.7 honor confidentiality.
- Professional responsibilities, such as high quality work, competence, knowing the rules that apply, professional review, thorough evaluation of risks, working only in areas of competence, accessing systems only when authorized, and 2.9: design and implement systems that are robustly and usably secure.
- Professional leadership principles, starting with 3.1: ensure that the public good is the central concern during all professional computing work; it also covers caring for systems when they are changed or retired, and taking special care with systems that become part of society's infrastructure.
- Compliance with the code: uphold and promote it, and treat violations as inconsistent with ACM membership.
The ACM code's four sections. Principle numbers make it easy to cite the exact principle you are applying.The IEEE Code of Ethics and the Software Engineering Code
The Institute of Electrical and Electronics Engineers (IEEE) code is shorter. It is organized in three sections. The section headings below are quoted from the code; the items after each heading are paraphrased summaries, not the code's exact wording:
- I. "To uphold the highest standards of integrity, responsible behavior, and ethical conduct in professional activities": put the safety, health and welfare of the public first, protect others' privacy, help society understand technologies (including intelligent systems), avoid conflicts of interest and bribery, accept and give honest criticism and correct errors, credit others' work, and work only within your competence.
- II. "To treat all persons fairly and with respect, to not engage in harassment or discrimination, and to avoid injuring others": this includes not harming others, their property, reputation or employment by false or malicious action.
- III. "To strive to ensure this code is upheld by colleagues and co-workers", including supporting those who report violations.
The Software Engineering Code of Ethics and Professional Practice (developed by the ACM and the IEEE Computer Society, 1999) has eight principles named for those a software engineer owes duties to or must care about: Public, Client and Employer, Product, Judgment, Management, Profession, Colleagues and Self. The first principle, Public, says software engineers shall act consistently with the public interest.
In Canada, the Canadian Information Processing Society (CIPS) has a code for IT professionals, and in Ontario the title "professional engineer" is protected and engineers licensed by Professional Engineers Ontario (PEO) must follow a code of ethics set in regulation.
The essential elements
Comparing codes, the same core elements appear again and again:
- The public good comes first, ahead of employer, client or personal gain.
- Avoid harm, including to the environment and to people outside the project.
- Honesty and integrity: no deception, honest claims about what software can do, admit and fix errors.
- Competence: only take on work you are qualified for; keep learning.
- Privacy and confidentiality.
- Fairness: no discrimination, in the workplace or in the software.
- Respect for intellectual property and credit for others' work.
- Quality and security: thorough testing, secure design, no backdoors.
- Accountability: report problems, support colleagues who raise concerns, and accept review.
Worked exampleExample 1: Applying the codes to a request
Your manager asks you to add a hidden account with a fixed password to a school-records app "so support can always get in if a customer locks themselves out". It won't be mentioned in the documentation. What do the codes say, and what should you do?
- This is a backdoor: a hidden way to bypass normal sign-in. If it is discovered, attackers can get into every school's records.
- ACM 2.9 (systems that are robustly and usably secure) and 1.6 (respect privacy) are violated: student records are exposed.
- ACM 1.3 (be honest and trustworthy) and IEEE section I (honest, responsible conduct) are violated because customers aren't told.
- ACM 3.1 and the Software Engineering Code's Public principle put the public (students, schools) ahead of the employer's convenience.
- Action: explain the risk to your manager in writing and propose a safe alternative: a documented, audited account-recovery process that requires the customer's verification. If you are overruled, use your organization's escalation process.
Decline to add an undocumented backdoor, explain the specific principles and risks, and propose a secure, documented recovery feature instead.
Detecting plagiarism with Python
Teachers and companies use software to flag possible code plagiarism. Renaming variables doesn't fool a good checker, because it compares the structure of code. The program replaces every name with ID, cuts the code into overlapping groups of three tokens (trigrams), and measures overlap with the Jaccard similarity: the size of the intersection divided by the size of the union.
import keyword
def tokens(code):
out = []
for word in code.replace("(", " ( ").replace(")", " ) ").replace(":", " : ").split():
if word.isidentifier() and not keyword.iskeyword(word) and word not in ("print", "range"):
out.append("ID")
else:
out.append(word)
return out
def trigrams(toks):
return {tuple(toks[i:i + 3]) for i in range(len(toks) - 2)}
def similarity(a, b):
ta, tb = trigrams(tokens(a)), trigrams(tokens(b))
return len(ta & tb) / len(ta | tb)
original = "for i in range(10): total = total + i"
renamed = "for k in range(10): s = s + k"
different = "while x > 0: x = x - 1"
print(round(similarity(original, renamed), 2))
print(round(similarity(original, different), 2))
Sets make it easy: & is intersection and | is union. A score of 1.0 means the structures are identical.
Output of the program above (what Python prints).
Just for funThe ACM code contains 25 principles. "Avoid harm" made the list.
"Never deploy on a Friday afternoon" did not, though many programmers treat it as unofficial principle number 26.
Hands-on activityWrite your own code of ethics
You need: paper or a document, and the ACM and IEEE codes (search for "ACM Code of Ethics" and "IEEE Code of Ethics" on the official acm.org and ieee.org sites).
- Read both codes. Highlight three principles from each that surprise you or that you think matter most.
- Write a one-page code of ethics for student programmers at your school with 6 to 9 principles. Each must include one of the essential elements and a concrete example (for example "We credit adapted code in comments with source and licence").
- Add a section on what happens when someone breaks the code and how a person can report a concern safely.
- Test your code on two scenarios: a friend asks to copy your assignment; your group's app collects more data than it needs. Does your code give clear guidance?
What to look for: principles tied to the essential elements, concrete examples, an enforcement and reporting section, and a test showing the code gives usable guidance.
Your turn
1Define a backdoor and a logic bomb.
Backdoor: a hidden way to bypass normal security or sign-in. Logic bomb: code that does damage when a condition is met (such as a date).
2Name the four sections of the ACM Code of Ethics.
General ethical principles; professional responsibilities; professional leadership principles; compliance with the code.
3What does ACM principle 1.2 say?
4Name the eight principles of the Software Engineering Code of Ethics.
Public, Client and Employer, Product, Judgment, Management, Profession, Colleagues, Self.
5Give three essential elements found in most codes of ethics for programmers.
Any three, for example: public good first, avoid harm, honesty, competence, privacy, fairness, respect for IP, quality and security, accountability.
6Why was the 2015 Volkswagen case a software ethics issue?
Engineers wrote software that detected emissions tests and changed engine behaviour to pass them, deceiving regulators and the public while cars polluted more on the road.
7What does the plagiarism program print for original and renamed, and why?
1.0: after names are replaced by ID, both have exactly the same token structure, so their trigram sets are identical.
More practice: warm-up
1What do the letters ACM stand for?
Association for Computing Machinery.
2What do the letters IEEE stand for?
Institute of Electrical and Electronics Engineers.
Software that secretly collects information about users.
4Which ACM principle says to respect privacy?
5What is the Jaccard similarity of two sets?
The size of their intersection divided by the size of their union.
More practice: on your own
1Find the Jaccard similarity of {1, 2, 3, 4} and {3, 4, 5}.
Intersection {3, 4} has 2 elements; union {1, 2, 3, 4, 5} has 5. Similarity = 2 ÷ 5 = 0.4.
2A developer quietly adds code that deletes the company's files if her account is ever removed. Name the type of code and two principles it violates.
A logic bomb. It violates ACM 1.2 avoid harm and 1.3 be honest and trustworthy (also IEEE section II, avoiding harm by malicious action).
3Why is "the public good comes first" placed above loyalty to an employer in these codes?
Software can affect many people who aren't part of the deal between programmer and employer. Professionals hold public trust, so the public's safety and welfare must outweigh an employer's or client's interests when they conflict.
4A free game app secretly uploads players' contact lists to sell to advertisers. Which kind of software is this, and which principles are broken?
It acts as spyware. It breaks 1.6 respect privacy, 1.3 honesty (it's secret) and the Public principle; it likely breaks privacy law as well.
5Why does the plagiarism checker replace names with ID before comparing?
So that renaming variables doesn't hide copying; the checker compares the structure of the code, not the names.
Challenge
1Compute by hand: tokens("while x > 0: x = x - 1") and the number of trigrams it has.
Tokens: while ID > 0 : ID = ID - 1 is 10 tokens ("while" is a keyword, so it stays; x becomes ID; ":" is separated). Trigrams: 10 − 2 = 8, all different, so the set has 8 elements.
2The plagiarism checker gives a high score to two students who both wrote a standard 3-line loop to sum a list. Explain why a high score is not proof of plagiarism and what a fair process should include.
Short, standard code is naturally similar: there are few sensible ways to write it. A fair process uses the score only as a flag, then a human looks at whole programs, unusual shared details (same mistakes, same odd comments), and talks to the students before deciding. This matches the codes' principles of fairness and honest evaluation.
3Compare how the ACM code and the Software Engineering Code are organized. Why might each structure be useful?
ACM is organized by type of obligation (ethical principles, professional responsibilities, leadership, compliance), useful for any computing professional. The Software Engineering Code is organized by who you owe duties to (public, client and employer, product, colleagues...), useful when a decision involves conflicting stakeholders. Both put the public first.
Check your understandingQuiz
1. Which is the best description of a backdoor?
2. Which ACM principle states that the public good should be the central concern of professional computing work?
3. The Software Engineering Code of Ethics is organized around…
4. What is the Jaccard similarity of {a, b, c} and {b, c, d, e}?
5. Why do codes of ethics exist when laws already forbid some harmful acts?
6. In the 2015 Volkswagen case, what did the software do?
For parents and teachersBig idea: D2.2 asks students to describe the essential elements of a code of ethics for programmers (such as the ACM and IEEE codes) and explain why such codes are needed (plagiarism, backdoors, viruses, spyware, logic bombs).
How to help: If your own profession has a code of ethics, share it and compare it with the ACM code. Discuss Example 1: what would your teen do if a boss asked for something unsafe? Help them practise saying "no" with reasons and an alternative.
Common difficulties:
- Mixing up the types of malicious code (a virus spreads itself; a logic bomb waits for a trigger; a backdoor bypasses sign-in; spyware collects information).
- Listing principles without applying them to a situation.
- Treating a plagiarism checker's score as proof. It only flags code for a human to review.
- The Therac-25 and Volkswagen cases involve real harm; discuss them respectfully as lessons about responsibility.