A study in attention After Johannes Vermeer

Tell it to the duck.

You have a bug. The duck has time. Explain the code in your own words, out loud or in ink, until you hear yourself say what is actually wrong. The duck will not help. That is the point.

fn checksum(bytes: &[u8]) -> u8 {    let mut sum = 0u8;    let updates = bytes.iter().map(|byte| {        sum = sum.wrapping_add(*byte);    });    drop(updates);    sum} 

The checksum is always zero, even when the bytes add up to something else.

To the duck0 sentences

  1. Okay, duck. The checksum is always zero, even when the bytes add up to something else.

Rubber duck debugging

Say it out loud.
Hear what you assumed.

Reading code, you fill the gaps with what you meant. Saying it to someone who cannot fill any gaps, you have to say what is there. The listener does not need to understand. The listener does not even need to be alive.

Nothing you say here leaves the room. The microphone, if you use it, is the browser’s own, and the duck keeps no notes.

Johannes Vermeer’s Woman in Blue Reading a Letter: a woman in a blue jacket stands in soft window light, absorbed in a letter held in both hands.
Johannes Vermeer, Woman in Blue Reading a Letter, c. 1663. Nobody is speaking. The light comes from the left.Rijksmuseum