A machine does not guess your intention
Tell a person, “Sort these students by grade,” and they will make assumptions. A machine needs every important rule to be explicit.
- Where do the students come from?
- Are all grades valid?
- Is the order highest to lowest?
- What happens when two grades are equal?
- What happens when a grade is missing?
Thinking like a machine means learning to remove ambiguity. It does not mean losing creativity.
Four questions for every task
- Input: What information is available?
- Output: What exact result is expected?
- Process: What ordered steps transform input into output?
- Exceptions: What unusual or invalid cases must be handled?
Example without code
Task: find the highest valid grade.
An algorithm is an ordered set of steps used to solve a problem. We can describe an algorithm using pseudocode, a readable notation that is not tied to a programming language.
In the example below:
INPUTidentifies the information receivedIFintroduces a decisionOUTPUTidentifies the result producedENDmarks the end of the instructions
INPUT: a list of grades
IF the list is empty
OUTPUT "No grade available"
OTHERWISE
IGNORE every grade below 0 or above 20
COMPARE the remaining grades
OUTPUT the greatest grade
END
The words are written in uppercase only to make the important operations easy to recognize. Pseudocode has no single mandatory syntax. Its purpose is to make the reasoning clear.
Activity: instruct a robot
Write instructions for a robot to prepare a glass of water. The robot cannot infer where the glass is, whether it is clean or when it is full.
Now test your instructions by following them literally. Mark every place where you had to guess.
1. Find one clean, empty glass in the cupboard.
2. If no clean glass exists, stop and report the problem.
3. Place the glass under the water tap.
4. Open the tap slowly.
5. Stop when the glass is approximately three quarters full.
6. Close the tap.
7. Place the glass on the table.
Even this version contains assumptions. For example, the robot needs a way to recognize a glass and measure three quarters. Precise thinking is an iterative process.
Manual testing
Test an instruction set with at least three cases:
- a normal case
- an empty or missing input
- an invalid input
You are already practicing an essential software engineering skill before writing code.
What you learned
- Machines follow explicit instructions and do not infer human intention.
- Every task needs defined inputs, outputs, steps and exceptions.
- Pseudocode expresses logic without the syntax of a programming language.
- Manual testing can expose missing decisions before implementation.
Knowledge check
- What is ambiguous about “show the best students”?
- Why should an empty input be tested?
- What is the difference between an algorithm and programming-language syntax?
- “Best” has no defined measure, number of students, ordering rule or treatment of equal grades.
- It reveals whether the instructions explain what happens when expected data does not exist.
- An algorithm describes the ordered logic of a solution. Syntax is the notation required to express that logic in a particular language.