Wrapping Up
We’ve reached the end of the book. We’ve discussed the advantages and disadvantages of four strategies to handle uncertain values in functions. With this knowledge, you can promote changes in your codebase to achieve a low maintenance cost. Let’s review what you’ve learned in this chapter:
-
Impure functions can result in unexpected values because they depend on values that are not in the function’s scope.
-
case, if, and other control-flow statements are good for handling simple cases. Combining multiple conditional statements produces code that’s hard to understand. You should avoid it.
-
The try statement works with libraries where you don’t control the code. These libraries can raise errors or throw values. Functions that return values ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access