I’m always mildly astonished when I see a script like the following — and this is the entire script by the way. It’s not that there’s anything horribly wrong with with it, but the architecture annoys me.
The thing I don’t like about the above script is that it is indented more than is actually necessary, negatively impacting readability. While this is a short script, and not that hard to follow, I’ve seen the same problem with scripts containing hundreds of steps. Here it is, slightly rearchitected.
In my opinion, this is already easier to read than the original version, and all I did was change the initial If operator from “=” to “<>” and throw in an Exit step. Can we apply the same trick a second time? Yes we can.
I find this substantially easier to read and understand than the original version. Nested If statements have their place of course, but why use them unnecessarily? Yes, this version is a few steps longer than the original, but I think the trade-off in terms of legibility is well worth it.