-
Notifications
You must be signed in to change notification settings - Fork 30
Description
(this is duplicated from gitbook discussion, because not sure where most people watch the project)
I like most of the guidelines of the book, however I find the judgment on "Single exit point" style overly harsh.
Single exit point is effectively mandated in most (all?) functional languages. Are you sure that Haskell "works at a lower level than Java"?
The "Single exit point" example is said "Overly complex", I don't really agree, but anyway the example is not fair. A good single return point style would be one of the method of gist.github.com/jbgi/c60acbfd7870237d0de6
The advantages of single return point associated with a final result variable (or no result variable) are two fold:
- you ensure proper case analysis. (you can easily forget one "return" in the case of multiple return style and then it silently slip through, like when you forget a break in a switch)
- you can easily extract part of the method into another: you cannot do that if the part of the method you want to extract contains a return: a single return point method can easily scale when more cases are added, a multiple return method cannot.
Can the overly harsh judgment be corrected ? or the section be removed all together ?