News for hackers. Stuff that matters.
Re:Why Python is Important for You by hcarvalhoalves on Saturday February 11, 2012 @07:56PM (#3580688)
Deeply nested code is usually a symptom of not thinking the problem in advance and solving it with data structures, instead relying on ad-hoc conditionals to solve it.

When I find myself testing against too many conditions, I usually refactor code to use a map between values and behaviour (e.g., a dict mapping regexs to function objects). This way you remove business logic from code, and are free to make it more algorithmic, like a simple mapping problem.

There are no comments on this comment yet.