News for hackers. Stuff that matters.
Re:Why Python is Important for You by nostrademons on Saturday February 11, 2012 @05:37PM (#3580388)
It works fine as long as the early returns are for error-checking or default values. Generally, you want each function to do one thing and do it well; one very effective way to structure this is to bail out early if that one thing can't be accomplished, and then have the body of the function actually do it.

If the actual logic requires many branching paths, then usually I'd reach for a more structured solution like a chain-of-responsibility pattern, fanout, or FSM. Also, you can get pretty far with a bunch of predicate functions composed together with 'and'.

There are no comments on this comment yet.