OTWONO LABS
Your account

OTWONO LABS / NOTEBOOK

Procedures: write instructions that handle ordinary and awkward cases

Learn one step at a time, with examples, practice and a place for your questions.

Start this lesson

Computing and logic · LESSON 3 OF 3

Turn a sorting rule into a sequence someone else can follow and test its boundary cases.

Before you start: Compare numbers with five. No programming syntax is needed.

Suggested pace: 20 to 35 minutes, with extra time for practice. You can stop after any section and return.

Start with something concrete

A fictional sorting desk puts objects at least five centimeters wide in box A and smaller objects in box B. Before writing instructions, establish the unit and confirm that ‘at least five’ includes an object exactly five centimeters wide.

The words we will use

Input
Information a procedure starts with.
Decision
A point where the next action depends on a condition.
Output
The result produced by the procedure.
Boundary
The exact value where a decision changes.

Understand the idea

A complete procedure needs more than the normal path. First obtain the width. Then check whether you have a valid measurement. Only then compare it with five. A missing width is not a measurement of zero.

For a valid width, ask whether it is greater than or equal to five centimeters. If yes, choose A. Otherwise choose B. State where the procedure stops so an operator does not keep sorting the same object.

Tests should exercise different paths. A width just below five tests B. Exactly five tests whether equality was handled correctly. Just above five tests A. Missing input tests the review path.

Teacher example: test the sorting desk

  1. Input 4.9 cm is valid and below five. Output B.
  2. Input 5.0 cm is valid and equal to five. Output A.
  3. Input is missing. Do not compare it as if it were a number. Output Review.
  4. Record the expected result beside each input, then compare the actual procedure with those expectations.
Each top box is an input and each lower box is its expected output. The missing measurement has its own review path. The arrows show decisions, not elapsed time.
Each top box is an input and each lower box is its expected output. The missing measurement has its own review path. The arrows show decisions, not elapsed time. Open the illustration for a larger view.

Connect the example to the rule

Writing the rule clearly also reveals questions for the owner of the process. Are negative values invalid? What measuring precision is accepted? What happens during review? Do not silently invent policy when the instructions leave it unresolved.

Your turn, with support

The desk receives a valid width of 5.1 cm. Follow the decisions in order and state the output.

Show one hint

After confirming validity, compare with the threshold including equality.

Compare your working

The width is valid and at least five, so it goes to A.

A mistake worth understanding

A rule using ‘greater than five’ sends exactly five elsewhere. That is a different rule from ‘at least five.’ Small wording differences can change the behavior at the boundary.

Check the idea before moving on

The interactive questions load when JavaScript is available. You can still use all written practice below.

Now solve without the example

  1. Write a rule that admits valid scores at least ten.
  2. Give expected decisions for 9, 10 and 11.
  3. State a separate path for an unavailable score.
Check the independent answers
  1. For a valid score greater than or equal to ten, admit; otherwise do not admit.
  2. Nine is not admitted. Ten and eleven are admitted.
  3. Use a defined review or retry path. Do not fabricate a score.

Use it in a new situation

A library sorts books by a printed code. What should happen when a book has two conflicting codes?

Compare a possible solution

Send it to an agreed review path. Ask which code is authoritative before assigning a shelf. The procedure must make uncertainty visible.

What to take away

Define inputs and outputs, order the decisions, handle missing information and test both sides of each boundary.

Before your next lesson

Close this page and explain the main idea in your own words. Rework one of the independent problems without looking. If a step is still unclear, return to the worked example and compare that exact step. Tomorrow, try the transfer problem again before opening its answer.

For a saved introductory check, open this lesson in your signed in workspace and choose Tests. Practice choices on this page are not a qualification or a substitute for independent work.

Open your lesson workspace

You reached the end of this introductory path. Browse another subject or revisit a lesson that needs more practice.