Loading lesson…
Level 1 · Apprentice0 XP
Wrap what to do in a value, so you can queue it, log it, retry it or undo it.
Step 1 / 5
ProblemA drawing app calls canvas.drawLine(), canvas.erase() directly from buttons. The user asks for undo. Nothing remembers what was done, so there is nothing to reverse.
← → step
Before this: Observer: tell everyone who cares
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Build a tiny text editor model with commands Append(text) and DeleteLast(count), each with run and undo, and a History with execute, undo and redo. Check that undo then redo returns the same text.