Professional Documents
Culture Documents
1
Step 4: Repair the Problem Step 5: Test Solution
Propose solution. Exact solution depends Obvious, but can be overlooked if
upon stage of problem.
Ex: late in code cannot change data structures.
programmer is sure they have fix (but
Too many other parts use. programmer can be wrong!)
Worry about “ripple” effects.
So, test that solution repairs bug
Id
Ideally,
ll wantt original
i i l coder
d tto fixfi
If not possible, at least try to talk with original Best by independent tester
coder for insights.
Test if other bugs introduced (beware
Consider other similar cases, even if not yet
reported “ripple” effect)
Ex: other projectiles may cause same problem
as arrows did
2
Game Maker – Debug Mode Game Maker – Print Debug Messages
Like show_message()
but in debug mode
only
Note, doesn’t pause
In code
show_debug_message
(“Executed this
code“)
Need to run in debug
mode
Ex: easy • Save/load Debug information
obj_hero.y • Look at instances, global
Tools
obj_hero.can_shoot variables, local variables Show messages
• Execute code
• Set speed
3
Debugging Tips (1 of 3) Debugging Tips (2 of 3)
One thing at a time Check code recently changed – if bug appears,
Fix one thing at a time – don’t try to fix multiple may be in latest code (not even yours!)
problems
Use debugger – breakpoints, memory
Change one thing at a time – test hypothesis.
Change back if doesn’t fix problem. watches, stack …
Start
St t with
ith simpler
i l case that
th t works
k - then
th add
dd more Break
B eak complex
comple calc
calculations
lations into steps – may
ma
complex code, one thing at a time be equation that is at fault or “cast” badly
Question your assumptions – don’t even assume Check boundary conditions – classic “off by
simple stuff works, or “mature” products one” for loops, etc.
Ex: libraries and tutorials can have bugs Minimize randomness –
Ex: can be caused by random seed or player
input. Fix input (script player) so reproducible
Debugging Tips (3 of 3)
Take a break – too close, can’t see it. Remove
to provide fresh prospective
Explain bug to someone else – helps retrace
steps, and others provide alternate
hypotheses
Debug with partner – provides new techniques
Same advantage with code reviews, peer
programming
Get outside help – tech support for consoles,
Web examples, libraries, …