Everyone loves a good if-else tower! What could be simpler than nesting a few conditionals?
Ok – that isn’t the most amazing thing in the world.
In a simple example like this, it isn’t too bad. But we all know real code is never easy to understand, especially after ten different people have changed it over the course of years!
But what can you do? Sometimes you have complicated logic, and implementing it without a leaning tower of if-elses can be nigh impossible.
Let me show you something called normalizer functions, and how they can help you get rid of some of that complexity.
Before we look at what a normalizer function is, here’s a quick example scenario.
... read the whole story at codeutopia.net.