-- Shakespeare, Love's Labour's Lost
What would an example of this look like? Let us look at one example with the FizzBuzz kata.
We see in the code above that the conditional statements around when to Fizz, Buzz, FizzBuzz, or just return the value given are more complex than they normally are.
Here is the Fizz condition:
We see that in the Fizz condition we are testing that it is a Fizz and that it is not a Buzz, this will allow us to relocate the this condition before the FizzBuzz condition if we want to, but only if the FizzBuzz condition will allow this (which it will).
Here is the Buzz condition:
We see that it is the reverse of the Fizz.
Here is the FizzBuzz condition:
We see that we are testing for both Fizz and Buzz conditions.
Finally here the else condition:
We see that we are looking for Not Fizz and Not Buzz. In a sense we have came up with our own little DSL around the logic of FizzBuzz and at the same time have written our conditions in such a way as to allow for them to be completely rearranged!