My team at work was working on some code katas and refactoring examples last week when came upon a particularly terrible piece of code. I won’t post the code in question, but let’s just say it consisted of nearly a dozen nested if statements. One of the devs was quick to term the awfulness as “IFception”.
(Found this via Google Image Search. My apologies, not sure who to contribute it to.)
We all got a laugh, but the term was pretty accurate. I’m sure most of you have heard the Inception joke about having a virtual machine within a virtual machine (etc..), and how it causes them to run really slow. Well the analogy is still pretty accurate with code. It might not always cause an application to perform slower, but it sure as hell slows down the developers who have to maintain the code. All of the developers on the team looked at the code and we decided it was best to leave it alone for now. It was that complicated and in such a critical area that we felt we’d get the best bang for our buck cleaning up some other area of the code. Yeah, it was that bad. It will need to be dealt with sometime, but that time was not Friday at 4pm.
I think Olivier expresses IFception quite well.
So the moral of this story is…? Please don’t do this, ever! Don’t make your fellow developers want to punch you in the throat. Have some pride as a professional. And if you do come across code like this, remember to bring your totem.