2. Locate where the bug most likely happens and start narrowing in:
- If possible, write a test that reproduces the bug.
- If the code where you believe the code is located is badly written clean up the readability as much as possible without making any semantic changes. Sometimes the bug will then stand out clearly and will be easily fixed.
- Figure out invariants, pre and postconditions in your code, and insert checks for them everywhere you can. If they fail, fix them, if that fixes your bug it's gone if not then you've just fixed a bug waiting to happen.
3. If this doesn't work for a prolonged period of time. Fix the bug by rewriting the entire mess. Giving up is a very efficient, but also very expensive debugging technique.
More later :-)