I was reviewing this morning a piece of code written by a beginner, when I found these lines:
If
...
ElseIf
...
ElseIf
...
Endif
I told him "Please, Do Not Use This". And the other guy sitting aside (more experimented) said: "Oh no DoN't Use This!". I think there are many reasons explaining this reaction:
- a bad experience when we first discover the instructions ("Great, it's like a SELECT but it allows to compare more than one variable") and were finally very disappointed trying to put together multiples overlapping elseifs that no one could ever never debugg properly ...
- The
elseif
trick does not allows you to align your lines of code as you've been doing it for the last 175 years, where you can visually check and adjust the quantity of endifs to add at the end of your procedure. - But most of all "what is the interest of something that is already correctly done by the traditionnal IF/ELSE/ENDIF or SELECT CASE statements?"
Another example of a DNUT/NDT item was this "cascade update" thing in SQL SERVER, which seemed to me at first glance a great trick ("Wohh! my keys are automatically updated anywhere in my database"), until I began to think that a really effective key should never be updated, so I banned the use of this cascade update thing in my databases a few hundred years ago, and, until today, nobody complains about that!
I am sure that each one of us has its own DNUT/NDT list, and I am sure there is plenty of time to spare by sharing this kind of knowledge!