Skip to main content
Building with AI (Vibe Coding)

⏱ About 15 min15 XP

One Change, Then Test

When your code is broken and you are frustrated, the temptation is to make a bunch of changes at once. Rename that variable, move that function, add a check, remove that line — maybe one of them will fix it. This strategy feels productive. It almost never is. When you change five things and the bug disappears, you have fixed the code but you have not learned anything. And when the bug does not disappear, you now have five changes to untangle.

Why One Change at a Time Works

The discipline of changing one thing and then testing is called controlled experimentation. Scientists use it. Doctors use it. Engineers use it. The logic is simple: if you change exactly one thing and the result changes, you know that one thing was responsible. This applies to debugging directly. Your bug is a fact about how your code behaves. Your change is a hypothesis: 'I think this is causing the problem.' Testing after each change is running the experiment. If you change multiple things, you cannot tell which hypothesis was right. You lose the ability to learn from what just happened. Controlled experimentation also prevents a common disaster: accidentally hiding a bug instead of fixing it. Sometimes a second change suppresses the symptom without fixing the cause. The bug is still there, lurking. You will find it at the worst possible time.

Controlled Experimentation

Change one thing. Test. Observe. Conclude. Only then change the next thing. This is not slow — it is the fastest way to find the real cause, because each test gives you information instead of noise.

Here is the process applied to a real scenario. You are building a form that should send data to a database when submitted. Nothing is being saved. Hypothesis 1: The submit button event listener is not firing. Test: add a console.log inside the listener. Result: the log appears. Conclusion: the listener fires correctly. Move on. Hypothesis 2: The data is not being extracted from the form fields correctly. Test: log the form data before sending. Result: the data looks correct. Conclusion: extraction is fine. Hypothesis 3: The database call is failing silently. Test: check the network tab; look for the request. Result: no request appears. Conclusion: the call is never made. The bug is between the data extraction and the database call. Each test narrowed the search by one step. Three small tests later, you know exactly where to look. That is faster than guessing and changing five things at once.

Complete the controlled experimentation cycle.

Change one , then it, then observe the , then draw a .

Applying This When Working With AI

When an AI gives you multiple suggestions — 'Try changing X, and also Y, and you might want to update Z' — resist the urge to apply all of them at once. Pick the one that addresses the most likely cause. Apply it. Test. Then come back and decide whether the next suggestion is still relevant. Sometimes applying suggestion 1 makes the bug disappear, and suggestions 2 and 3 were not only unnecessary but might have introduced problems. Sometimes applying suggestion 1 reveals that the real bug is something the AI did not mention at all. Either way, you learn something from each single test. That learning compounds. By the end of a debugging session where you change one thing at a time, you understand your code better than when you started.

When the AI Gives a List of Changes

Apply the highest-priority suggestion first. Test. Decide whether the others are still needed. Do not treat a list of suggestions as a recipe to execute all at once.

Why is changing multiple things at once a poor debugging strategy?

What does it mean to 'hide a bug' with a change?

The One-Change Challenge

  1. Take any small piece of code with a known bug (your teacher will provide one, or use one from a previous lesson).
  2. Before touching anything:
  3. 1. Write down your hypothesis: what do you think is wrong and why?
  4. Then:
  5. 2. Make exactly one change based on that hypothesis.
  6. 3. Test — does the bug still happen?
  7. 4. Write down what you observed.
  8. 5. If the bug persists, form a new hypothesis based on what you learned. Repeat.
  9. Keep a log: Hypothesis / Change Made / Result / Conclusion
  10. At the end, count how many cycles it took. Compare with a partner. Whose log shows the most learning per step?