4. Active Debugging

In passer-rating, you have a program that runs without crashing. This is an achievement, but a small one. Let’s explore it a little more and see if we can’t turn it into a program that works. This entails a small test, and maybe some probing of the inner workings.

A Simple Test Case

Run passer-rating again. Give it the old data set if you like, for a short, mediocre game; but also try a rating for a quarterback who didn’t play at all:

comps, atts, yards, TDs, INTs: 10 20 85 1 0Rating = 89.4comps, atts, yards, TDs, INTs: 0 0 0 0 0Rating = nancomps, atts, yards, TDs, INTs:

H’m. Not what you expected. It doesn’t crash, but it’s wrong. A performance in which a passer never passed should be rated ...

Get Xcode 6 Start to Finish: iOS and OS X Development, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.