Interesting (and clean!) use of goto.
Originally posted on Life As I Know It:
Well all the programmers know that “Goto is bad”. Now-a-days people are avoiding it and many languages do not support it. The following sketch by xkcd also summarizes the harmfulness of Goto.
And poor Goto has been taken to task by none other than Dijkstra. I used to be a strong opponent of Goto as well.
But while going through the book Advanced Mac OS X Programming by Mark Dalrymple and Aaron Hillegass, the frequent use of Goto made me change my opinion. The authors have used Goto elegantly to avoid conditional nesting.
Those who code in languages like C or C++ with no or half support for exceptions need to depend on error codes to determine the success or failure of a method. Suppose we write a method which is dependent of 5-6 more methods to do the task. After invoking each method we need to check the…
View original 308 more words