News for hackers. Stuff that matters.
Re:Confident Code by mattmanser on Thursday November 10, 2011 @05:55AM (#3219675)
I tried to code like this already, but one scenario I've found that is ruining this style is external API calls.

I'm now finding my code heading back to the old littered style whenever I have to update or get information from someone else's API just because I have to handle potential failure there and then.

Very frustrating, anyone got any insights on how they're dealing with it?

Re:Confident Code by avdi on Thursday November 10, 2011 @04:37PM (#3221995)
I almost invariably isolate any API calls behind some kind of wrapper facade. In fact, a lot of the presentation is about exactly that: adapting Ruby's IO primitives--which can raise various exceptions, and may return a process exit status in the form of a global variable--in code that isolates their idiosyncrasies.