Topic 11 ยท Programming Scenarios ยท 11.1

Programming Scenarios

Learn how to read a programming problem, identify what it requires and plan a clear solution before writing any code.

Invitation

Would you build before reading the instructions?

Imagine assembling a piece of furniture without first checking the instructions. You might begin quickly, but you could miss a part or build something in the wrong order.

Programming scenarios work in the same way. Before writing code, you need to understand exactly what the problem is asking you to do.

Good programmers do not begin with code. They begin by understanding the problem.
The safe route
Read the problem
โ†“
Plan the solution
โ†“
Write the algorithm
Big Idea

A scenario describes a problem to solve

In an algorithms and programming question, the scenario explains what the program must do.

Your job is to turn those requirements into a clear algorithm using pseudocode or program code.

ScenarioWhat must happen?
โ†’
PlanWhat steps are needed?
โ†’
SolutionWrite the algorithm.
The algorithm is the solution. The scenario tells you what that solution must achieve.
Computational Thinking

Use four thinking skills to make the problem manageable

A programming scenario can look complicated when you see it as one large task. Computational thinking helps you turn it into smaller, clearer decisions.

DecompositionBreak the scenario into smaller requirements.
Pattern RecognitionLook for familiar patterns such as input, validation, selection, iteration, counting and totalling.
AbstractionIgnore story details that do not affect the solution. Keep the important data and rules.
Algorithm DesignArrange the required steps into a clear and logical order.
A large programming problem becomes easier when computational thinking turns it into manageable pieces.
Visual Guide

Move from scenario to algorithm

Decompose
Split the requirements.
โ†’
Recognise patterns
Find familiar programming structures.
โ†’
Abstract
Keep only what matters.
โ†’
Design the algorithm
Put the steps in order.
Scenario โ†’ Decomposition โ†’ Patterns โ†’ Abstraction โ†’ Algorithm.
Visual Guide

Read the scenario twice

The first reading helps you understand the overall problem.

The second reading helps you find every individual requirement.

First read
Understand the story.
โ†’
Second read
Find each requirement.
A second reading prevents small but important instructions from being missed.
What are you looking for?
What data enters?
What must happen?
What result is produced?
Bridge

Every game began as a scenario

Consider a character moving around a computer game. The programmer first had to describe what should happen when the player presses a key.

InputThe player presses the right arrow key.
ActionThe character's horizontal position increases.
ResultThe character appears in the new position.
One small scenario
Right arrow pressed
โ†“
Increase x position
โ†“
Character moves right
Two Methods

There is more than one way to plan

Method 1Identify the inputs, processes and outputs.
Method 2Act out the task and record each stage.
Same goalCreate a complete, ordered solution.
Choose the method that helps you understand the problem most clearly.
Hinge Question

Why plan before writing code?

Question

What is the main risk of starting to code before identifying all the requirements?

โ€œYou may miss part of the problem, place the steps in the wrong order or produce a solution that does not meet every requirement.โ€
Exam Explainer

Turn the question into a checklist

1Read the scenario twice.
2Underline each requirement.
3Plan before coding.
Exam tip: Return to the scenario when you finish and check that your algorithm performs every stated requirement.
Common Mistake

Starting with code too quickly

โœ— Rush

Begin writing statements after reading only the first line.

The solution may work partly but miss important requirements.

โœ“ Plan

Read twice, identify the requirements and choose an approach.

The code then has a clear purpose and order.

Remember: Fast coding is not useful if it solves the wrong problem.
Summary

Think first. Plan second. Code third.

DecomposeBreak down the scenario.
RecogniseFind familiar patterns.
DesignArrange the algorithm.
Final rule: A successful algorithm begins by applying computational thinking to the problem.