Bitpath

Lesson 2 · Unit 01

Trace it

Follow calls down and values back

12 exercisesabout 3 min

What you practise

  • Follow the call chain, predict what a function returns from code alone, track where a value comes from, search for a name and read its call sites

Try a question from this lesson

Pick one

Follow the rate from where it is defined to where it is used. What does this print?

DEFAULTS = {"rate": 5}

def load(overrides):
    config = dict(DEFAULTS)
    config.update(overrides)
    return config

def price(qty, config):
    return qty * config["rate"]

cfg = load({"rate": 7})
print(price(3, cfg), DEFAULTS["rate"])
const DEFAULTS = { rate: 5 };

function load(overrides) {
  return { ...DEFAULTS, ...overrides };
}

function price(qty, config) {
  return qty * config.rate;
}

const cfg = load({ rate: 7 });
console.log(price(3, cfg), DEFAULTS.rate);
type Config = { rate: number };
const DEFAULTS: Config = { rate: 5 };

function load(o: Partial<Config>) {
  return { ...DEFAULTS, ...o };
}

function price(qty: number, c: Config) {
  return qty * c.rate;
}

const cfg = load({ rate: 7 });
console.log(price(3, cfg), DEFAULTS.rate);
Hint

Find where the table used for the price is built, and which entry wins when both tables have one.

The idea

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Down for control, back for data

Two questions, two directions.

"What happens when this runs?" Read downward: follow the calls from the entry point.

"Where does this value come from?" Read backward: from the line that uses it to every line that could have set it.

Most bug hunts are the second question.

10 more exercises in the app

  • 4× type the answer
  • 1× fill the blanks
  • 2× multiple choice
  • 1× true or false
  • 1× order the lines
  • 1× match the pairs

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy