Identification
A Little Bit of This, a Little Bit of That
If you work as a professional software developer, then you must have seen code like this before. Truth be told... we've all written code like this before:
if(user.role === "admin" && user.isActive && user.permissions.some(p => p === "edit")) { // Do stuff }
I know you've seen this before – and versions of this that are much worse and more complex!
These long lists of conditionals we find inside our if
statements can be called verbose conditionals:
- They are hard to read.
- They are hard to understand once you've read them.
- They are hard to modify.
- They are hard to test (well... you can't really directly test them at all).
Misbehaving Conditionals
These lengthy conditionals often lead to software that will misbehave and not work the way you would want it to.
More often than not, when we find bugs in these...