if f.exists = false generates NilObjectException

I prefer the style Norman describes too. Bail early and leave early (if you can). This way the code that’s left will always be run in normal circumstances.

It also reduces on the code indentation density. Every If then else, for next loop, etc, increases the indentation and makes it hard to read (IMO). I even wrote up an article about it a while back: http://www.bkeeneybriefs.com/2012/12/code-indentation-density/

The other thing I try real hard to do is keep my methods short enough so that I don’t have to scroll. If I find myself scrolling I will often take a chunk out into a separate method. This helps with error handling too. Hard to find that Nil Object Exception in a method that has 500 lines of code. Whereas if the method has 20 lines of code I’ll probably have a good guess at what caused it.