An interesting post about Where Bugs Come From — the computer kind, not the creepy crawly kind (we know where those come from).
…[A] classic tale of slippery assimilation, trying to find that ridiculous cut-off point where a program went from being short enough to be bug-free, to long enough to be inevitably buggy…This, of course, is the promise of structured programming, of functions, of objects. If we can write 137 lines of code without a bug, then we can structure our programming style so that were always writing units of fewer than 137 lines. We can build those units into components, and voila! No more bugs.
If only it were so simple! Having used various approaches to programming — from the by-the-seat-of-the-pants methodology to hard-core unit testing for each and every class that's written — I can say that there's no magic bullet, no magic number of lines, no magic anything. It's just freakin' work, and lots and lots of testing, to get your software to the point that it does what it's supposed to, and when it doesn't, to gracefully alert the user that something's gone amiss.