Lesson Overview
Improve a second artefact with better structure, testing and maintenance evidence.
Portfolio focus: Choose one feature to improve.
Starter: think before typing
Before running this portfolio review 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 `Before review: 105 After review: 100`; predict how the focus line helps produce that evidence.
Learning Objectives
- Use feedback from the first artefact.
- Improve code structure and naming.
- Show stronger testing and maintenance notes.
- Evaluate progress against module-level programming skills.
Learning Outcomes
- By the end of the lesson, you can use feedback from the first artefact.
- By the end of the lesson, you can improve code structure and naming.
- By the end of the lesson, you can show stronger testing and maintenance notes.
- By the end of the lesson, you can evaluate progress against module-level programming skills.
Why this idea exists
Review is how programming improves from activity into discipline. Early code often works by accident; reviewed code becomes easier to reason about, maintain and explain.
Refactoring developed as a way to improve internal structure without changing external behaviour. It recognises that design is not always perfect up front, but improvement should be controlled and evidence-based.
A strong second artefact should show progression: clearer naming, better validation, more focused methods, stronger tests and a reflection that explains what changed in your thinking.
Deep dive
Mechanism in this example
The important mechanism is visible around `int safeMark = clampMark(rawMark);`. 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
A strong second artefact should show progression: clearer naming, better validation, more focused methods, stronger tests and a reflection that explains what changed in your thinking.
Failure mode to watch
For Portfolio Artefact 2 and Review, deliberately disturb the assumption behind `int safeMark = clampMark(rawMark);`: 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 portfolio review design.
Extension step
Extend the example by doing this: Refactor with evidence. 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: write a final reflection linking skill growth to the software lifecycle.
Lesson visual

Type this and run it
Create PortfolioArtefact2ReviewDemo.java, type the program, and run it before changing anything. This section is about reproducing the checked baseline.
public class PortfolioArtefact2ReviewDemo {
public static void main(String[] args) {
int rawMark = 105;
int safeMark = clampMark(rawMark);
System.out.println("Before review: " + rawMark);
System.out.println("After review: " + safeMark);
}
static int clampMark(int mark) {
return Math.max(0, Math.min(100, mark));
}
}Build and run it with:
javac PortfolioArtefact2ReviewDemo.java && java PortfolioArtefact2ReviewDemoExpected baseline: Before review: 105
After review: 100
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 portfolio review and compare the new behaviour with the reference output.
Before review: 105
After review: 100Line-by-line explanation
Read the code as a sequence of responsibilities. The focus line for this lesson is int safeMark = clampMark(rawMark);; the surrounding lines prepare it, use its result or make the behaviour observable.
public class PortfolioArtefact2ReviewDemo {This names the runnable class for the Portfolio Artefact 2 and Review example, giving the compiler and JVM one clear unit to build.
public static void main(String[] args) {This is the program entry point. In Portfolio Artefact 2 and Review, it keeps the demonstration of portfolio review in one traceable starting script.
int rawMark = 105;This introduces rawMark as named state for Portfolio Artefact 2 and Review. Later lines can read, update, pass or print that specific value as evidence.
int safeMark = clampMark(rawMark);This introduces safeMark as named state for Portfolio Artefact 2 and Review. Later lines can read, update, pass or print that specific value as evidence.
System.out.println("Before review: " + rawMark);This prints "Before review: " + rawMark as the observable evidence for Portfolio Artefact 2 and Review. The output lets the learner check whether the portfolio review idea behaved as predicted.
System.out.println("After review: " + safeMark);This prints "After review: " + safeMark as the observable evidence for Portfolio Artefact 2 and Review. The output lets the learner check whether the portfolio review idea behaved as predicted.
}This closes the innermost Portfolio Artefact 2 and Review block, so the immediately preceding method, branch or loop has finished.
static int clampMark(int mark) {This starts clampMark, a named Portfolio Artefact 2 and Review operation. Its parameters describe what information comes in; its body decides what work is done.
return Math.max(0, Math.min(100, mark));This sends a Portfolio Artefact 2 and Review result back to the caller, so the surrounding code can use the answer.
}This closes the outer Portfolio Artefact 2 and Review structure, returning the reader to the surrounding class or file.
}This closing brace number 3 completes another layer of the Portfolio Artefact 2 and Review source structure Java has been checking.
Worked example
From code to explanation
Problem: Use Portfolio Artefact 2 and Review to complete a small portfolio-quality step: Choose one feature to improve.
Method: Locate the line `int safeMark = clampMark(rawMark);`, 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 `Before review: 105 After review: 100`. A strong answer links the result back to portfolio review: 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 portfolio review concept depends on.
During: Trace `int safeMark = clampMark(rawMark);` as the Portfolio Artefact 2 and Review 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: `Before review: 105 After review: 100`.
Change: Now refactor with evidence, run again, and explain the smallest reason the behaviour changed.
Common misconception
A common mistake in portfolio artefact 2 and review is treating the example as a finished answer. For portfolio review, 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 Portfolio Artefact 2 and Review example, what is the best reason to focus on `int safeMark = clampMark(rawMark);`?
2. Which evidence is strongest after you edit and rerun this example?
How to study this lesson
For Portfolio Artefact 2 and Review, predict how portfolio review changes the run before you press Run.
Use the first portfolio task as your main edit: Choose one feature to improve.
Use the second task as your variation: Refactor with evidence.
Finish with evidence, not a diary entry: Write a final reflection linking skill growth to the software lifecycle.
Portfolio Practice
- Choose one feature to improve.
- Refactor with evidence.
- Write a final reflection linking skill growth to the software lifecycle.
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 Before review: 105
After review: 100 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 portfolio review.
Study route
Practise portfolio review by predicting the Java example, typing it, running it in the browser, tracing the result and saving portfolio evidence.
This is the final lesson in the route, so use it to audit the whole portfolio for runnable examples, test evidence and honest reflection.
