Just read an article in the PyCoders weekly list about refactoring functions to have multiple return points.
The article is well-written, but I was floored by the need for it. I've been an advocate of multiple return points for 2 decades.
The only reason to hold to a single return point in a function is to guarantee release of resources, and every OO language has had a means to do that with a local variable and destructor for over 25 years.
Multiple return points make the logic clear, handle special cases better, and allow better refactoring later for all purposes.
No comments:
Post a Comment