CoreData error

John Shockey john at johncshockey.com
Wed Jun 18 12:24:16 EDT 2014


Owen,

Thanks.

I don't know how many folks are on this list. I don't think the ones
I've heard from today need this, but here's a list of debugging tips.

If it's an easy bug, just do whatever works. But if you're stuck,
consider:

1. The most important debugging tool is your brain.

2. Look hard at all the information you gather. Don't worry so much
about immediately finding the bug. Just look for anything that isn't
what you expected. Try to understand it, and you may find the bug shows
itself in the process. (That was the solution for today's bug.)

3. Try single stepping through your code. I often do this with new code,
especially if it's at all complicated, even if no bugs have shown up.
While stepping, follow rules 1 and 2.

4. If an API call doesn't behave the way you expect, don't be too quick
to decide it's a bug in the API. Think as if you were implementing that
API -- what information would you have available, and how could you make
it work?

5. Multi-threading issues have their own rules. Treat them like a math
problem and try to prove you code correct. Alternatively, treat it as a
puzzle and look for an exception. This is more theoretical than most
debugging. Multi-threading issues are difficult!

6. If a bug is really hard to reproduce (see especially #5), don't give
up easily when it finally occurs. I've been known to leave my debugger
stopped on a bug for a day. It's slow, but if it takes you days to make
it happen it's often worth it.


Anyone else have any favorites?

John


More information about the MacTechGroup-discuss mailing list