Free degree-level programming lessons for careful independent study.

Degree Level Programmes · Programming 1 · Lesson 17

Professional, Ethical and Legal Practice

Connect beginner programming choices to copyright, privacy, accessibility, security and professional responsibility.

Lesson Overview

Connect beginner programming choices to copyright, privacy, accessibility, security and professional responsibility.

Portfolio focus: Audit a small app idea for personal data.

ConceptProfessional practice
Run fileProfessionalEthicalLegalPracticeDemo.java
BaselineRedesign: do not collect data without a clear purpose.
Evidence3 tasks

Starter: think before typing

Before running this professional practice example, find the line where the main idea becomes active. Write a prediction: what must already be true for that line to work, and what should be different after it runs? The checked run ends with `Redesign: do not collect data without a clear purpose.`; predict how the focus line helps produce that evidence.

Learning Objectives

  • Identify legal, social, ethical and professional risks in software.
  • Explain why personal data needs care.
  • Use licences and attribution appropriately.
  • Make a small program more accessible or secure.

Learning Outcomes

  • By the end of the lesson, you can identify legal, social, ethical and professional risks in software.
  • By the end of the lesson, you can explain why personal data needs care.
  • By the end of the lesson, you can use licences and attribution appropriately.
  • By the end of the lesson, you can make a small program more accessible or secure.

Why this idea exists

Software engineering became a profession because code increasingly affects real people: privacy, safety, work, education, money, accessibility and public trust can all depend on software decisions.

Legal and ethical practice has developed alongside computing itself, from copyright and licensing questions to data protection, security duties and the social consequences of automation.

At degree level, professionalism means looking beyond whether code runs. You should ask who is affected, what data is collected, what harm is possible, what assumptions are hidden and what responsibilities the developer has.

Deep dive

Mechanism in this example

The important mechanism is visible around `boolean collectsPersonalData = true;`. Read it as a concrete move in the program, not as decorative syntax: identify what value, object, branch, call or boundary is being created at that point.

Design pressure

At degree level, professionalism means looking beyond whether code runs. You should ask who is affected, what data is collected, what harm is possible, what assumptions are hidden and what responsibilities the developer has.

Failure mode to watch

For Professional, Ethical and Legal Practice, deliberately disturb the assumption behind `boolean collectsPersonalData = true;`: use an awkward value, missing input, wrong order of calls or boundary case. The useful question is how that disturbance exposes a weakness in the professional practice design.

Extension step

Extend the example by doing this: Write one accessibility improvement. The point is to make one small change that forces you to revisit the concept, rather than adding unrelated features.

Portfolio standard

The portfolio note should not repeat the lesson wording. It should show the edited code, the run result, and your own explanation of this evidence: add an attribution note for any external resource.

Lesson visual

A realistic software team desk with privacy checklist, accessibility notes, licence labels and code review comments.
A realistic software team desk with privacy checklist, accessibility notes, licence labels and code review comments.Download visual

Type this and run it

Create ProfessionalEthicalLegalPracticeDemo.java, type the program, and run it before changing anything. This section is about reproducing the checked baseline.

public class ProfessionalEthicalLegalPracticeDemo {
  public static void main(String[] args) {
    boolean collectsPersonalData = true;
    boolean hasClearPurpose = false;
    if (collectsPersonalData && !hasClearPurpose) {
      System.out.println("Redesign: do not collect data without a clear purpose.");
    }
  }
}

Build and run it with:

javac ProfessionalEthicalLegalPracticeDemo.java && java ProfessionalEthicalLegalPracticeDemo

Expected baseline: Redesign: do not collect data without a clear purpose.

Run the code in your browser

Use the editor as an experiment surface. First run the checked version, then make one small change to the part of the program that demonstrates professional practice and compare the new behaviour with the reference output.

Line-by-line explanation

Read the code as a sequence of responsibilities. The focus line for this lesson is boolean collectsPersonalData = true;; the surrounding lines prepare it, use its result or make the behaviour observable.

public class ProfessionalEthicalLegalPracticeDemo {

This names the runnable class for the Professional, Ethical and Legal Practice example, giving the compiler and JVM one clear unit to build.

public static void main(String[] args) {

This is the program entry point. In Professional, Ethical and Legal Practice, it keeps the demonstration of professional practice in one traceable starting script.

boolean collectsPersonalData = true;

This introduces collectsPersonalData as named state for Professional, Ethical and Legal Practice. Later lines can read, update, pass or print that specific value as evidence.

boolean hasClearPurpose = false;

This introduces hasClearPurpose as named state for Professional, Ethical and Legal Practice. Later lines can read, update, pass or print that specific value as evidence.

if (collectsPersonalData && !hasClearPurpose) {

This makes the Professional, Ethical and Legal Practice decision point. Trace the condition first, then trace only the branch that can actually run.

System.out.println("Redesign: do not collect data without a clear purpose.");

This prints "Redesign: do not collect data without a clear purpose." as the observable evidence for Professional, Ethical and Legal Practice. The output lets the learner check whether the professional practice idea behaved as predicted.

}

This closes the innermost Professional, Ethical and Legal Practice block, so the immediately preceding method, branch or loop has finished.

}

This closes the outer Professional, Ethical and Legal Practice structure, returning the reader to the surrounding class or file.

}

This closing brace number 3 completes another layer of the Professional, Ethical and Legal Practice source structure Java has been checking.

Worked example

From code to explanation

Problem: Use Professional, Ethical and Legal Practice to complete a small portfolio-quality step: Audit a small app idea for personal data.

Method: Locate the line `boolean collectsPersonalData = true;`, explain the exact role it plays, then decide what you would change to extend the example without changing the whole program.

Reveal worked answer

The checked run should produce `Redesign: do not collect data without a clear purpose.`. A strong answer links the result back to professional practice: what was created, selected, stored, called or protected, and why that matters for the portfolio task.

Trace the program

Before: Before the key operation, identify the relevant value, object, branch or resource that the professional practice concept depends on.

During: Trace `boolean collectsPersonalData = true;` as the Professional, Ethical and Legal Practice example executes. Say whether that operation creates data, checks a condition, calls behaviour, stores information or crosses a boundary.

After: Compare the run with the expected evidence: `Redesign: do not collect data without a clear purpose.`.

Change: Now write one accessibility improvement, run again, and explain the smallest reason the behaviour changed.

Common misconception

A common mistake in professional, ethical and legal practice is treating the example as a finished answer. For professional practice, the important question is narrower: which operation carries the idea, what does it make possible, and what would break if you changed it carelessly?

Quick checks

1. In this Professional, Ethical and Legal Practice example, what is the best reason to focus on `boolean collectsPersonalData = true;`?

2. Which evidence is strongest after you edit and rerun this example?

How to study this lesson

For Professional, Ethical and Legal Practice, predict how professional practice changes the run before you press Run.

Use the first portfolio task as your main edit: Audit a small app idea for personal data.

Use the second task as your variation: Write one accessibility improvement.

Finish with evidence, not a diary entry: Add an attribution note for any external resource.

Portfolio Practice

  1. Audit a small app idea for personal data.
  2. Write one accessibility improvement.
  3. Add an attribution note for any external resource.

Final self-check

Can you explain the key operation?

Explain the line identified in the quick check in one or two sentences. Your answer should say what it does before the output Redesign: do not collect data without a clear purpose. appears.

Can you justify the portfolio evidence?

Your evidence should include the original run, one edited run, and a short note explaining how the edit affected professional practice.

Study route

Practise professional practice by predicting the Java example, typing it, running it in the browser, tracing the result and saving portfolio evidence.

Next, move into Portfolio Artefact 1: Console Application and carry forward one improvement from this lesson into the next program.