#27: Simplifying Complex if Statements
Hello! Today, let’s discuss how to handle complex if statements in our code.
Imagine we are reading a codebase we are not yet familiar with. This is the codebase for a coffee shop system. We come across the following piece of code1:
The number of conditions and the nested levels in the if
statement make the code very hard to read and understand. To improve the readability of the code, we can create dedicated variables for each condition:
Keep reading with a 7-day free trial
Subscribe to The Coder Cafe to keep reading this post and get 7 days of free access to the full post archives.