Deep nesting in code hid a problem from me
Deeply nested code is a pain to read. Here's some more proof. The other day, I wrote about replacing some broken code. In it, I provided an example of what a huge block of nested if-then-elses might look like. It looked like this:
Note that I said looked, as in past tense. This morning I was working on fixing a different part of that post based on some reader feedback, and then noticed it: I mismatched my blocks! Even though I tried to be very careful about this for my post, I still made a mistake.
The code as shown above doesn't say "machine is offline" when it's offline. It says it when the base install isn't OK. It doesn't say anything when the machine is actually offline. Worse yet, it never does anything to solve the actual problem: a bad base install!
I've fixed the old post so it doesn't trip anyone up. I've preserved the broken version of it here as a screenshot to demonstrate just how subtle the problems of "crowded code" can be.
Let your code roam free and breathe! White space is good!