Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Decide When a Plan Pays Off

In this video, you followed one wrong choice through a toy version of the escape room project, made for the video, and then asked the same question about a small change.

Key points:

  • The toy plan had one line about how the code holds a room: “its name and a list of puzzle names, in order.” The loader kept only the names, and dropped each puzzle’s needs and unlocks.
  • Your agent built each later step from the plan, so the checker, both tests, and the command that prints the verdict were all built on that list. One test expected the first puzzle to be a plain name, the brass telescope. The tests passed, and the checker said The Smuggler’s Cellar can be finished, though its iron strongbox needs a key no puzzle unlocks.
  • Fixing the shape in code changed five files. The loader and both tests changed, the checker was rewritten to name the puzzles it can’t reach, and the command that prints that answer changed with it. Your agent can make those edits in one task, but you still review and re-test all five.
  • The brief asks for every puzzle a team can’t reach, so checking the plan against the brief would have caught the line. In the plan, the same fix is one line: “its name and its puzzles, each with its needs and unlocks.” The project is a toy. In a real one, every file that uses the shape directly adds to that count.
  • A usage line for when no room file is given is different. Nothing later builds on it, it touches one place, and the approach is clear, so it can go straight to your agent as a task. Ask for the change directly, with no plan step, then run it to check. In the toy, it changed one file. Read Git’s summary after your agent’s change, and if it touched more, take a look.

The rule is to plan first when later code will build on a choice, such as the stack, the shape of the data, or the folder structure. A change that touches one place, with an approach you can see, can go straight to a task.

Here’s the toy’s code after the fix, where each puzzle keeps its needs and unlocks. It’s a toy made for the video, so it’s small: the broken room, the loader, the checker, and the command that prints the verdict.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 Your escape room project now has a brief and a plan, both committed. Getting that plan took a whole lesson.

00:08 So does every change deserve one? In this video, you’ll follow one wrong choice through a growing project. Then you’ll ask the same question about a small change.

00:21 Here’s a toy version of the project, made for this video. Its plan has one line about how the code holds a room: its name and a list of puzzle names, in order.

00:32 That line is wrong on purpose, so you can follow it. The room files keep each puzzle’s needs and unlocks. The loader reads a file and keeps only the names.

00:44 So in the code, the Lighthouse Keeper’s Study becomes six names in a row. Nothing says which puzzle opens which.

00:54 Now your agent builds the project from the plan, one step at a time, and each step builds on that shape. The checker gets the list. With no needs or unlocks to look at, it can only say whether the room has puzzles at all.

01:10 The tests are written against the same list. One expects the first puzzle to be a plain name, the brass telescope. The other expects that any room with a puzzle can be finished.

01:22 The command that prints the verdict reads the checker’s answer. Run the tests, and both pass.

01:30 Then you try the second sample room, The Smuggler’s Cellar, which is the broken one. Its iron strongbox needs the iron key, and no puzzle unlocks it. So the strongbox and the trapdoor after it can never be reached.

01:44 Your turn: pause the video and predict what the checker prints for this room, even with two puzzles out of reach.

01:56 It prints that the room can be finished. The checker never had the needs to look at. And the tests agreed with it, because they were built on the same list.

02:09 To fix it, you need a new shape, where each puzzle keeps its needs and unlocks.

02:15 With that shape, the checker prints that the room can’t be finished, and names the strongbox and the trapdoor.

02:23 Now count what changes. The loader changes, and so do both tests. The checker is rewritten to name the puzzles it can’t reach, so the command that prints its answer changes too.

02:36 Git’s summary line says five files changed. Your agent can make those edits in one task, but you still review and re-test all five. And the brief asks for every puzzle a team can’t reach, so checking the plan against it would have caught that line.

02:54 In the plan, the same fix is one line. This project is a toy. In a real one, every file that uses the shape directly adds to that count.

03:06 Now a different change. Run the command with no file, and it should say how to use it. Ask the same question as before: will later code build on this? Nothing will.

03:20 It touches one place, the command, and you can already see how to do it. So give it to your agent as a task. Ask for the change directly, with no plan step, then run it to check.

03:32 In the toy, it prints a usage line. Then read Git’s summary, which shows one file changed. If your agent touched more, that’s worth a look.

03:44 So the test is about what builds on a choice. Plan first when later code will build on it: the stack, the shape of the data, the folder structure. A change that touches one place, with an approach you can see, can go straight to a task.

04:02 Next, in the exercise Review a Plan Against the Brief, you’ll check a plan’s steps against an escape room brief yourself.

Become a Member to join the conversation.