Dear god, I think this would be what would drive coders mad if some Lovecraftian old one were a coder. I have a colleague that writes code like that last one. I know he won't change, but I wish he'd at least use a damned switch statement.
Yes, I'm thinking of some mad-scientist types I've met who spin out WTF-worthy code on a daily basis. They love computers and programming, and can get workable output eventually, but it's terrible code.
I have encountered code written by people just psycho enough to think that's a clever way to handle just that scenario. They were not wrong it was indeed clever. It was also terrible.
A function that consisted of a giant switch statement, with each case consisting of another switch statement. Half of the sub-cases contained GOTO statements back to the top of the function.
Even worse... I wrote the code. It was 2am, I had been working for 18 hours straight to get everything ready for a demo the next morning.
Even worse than that... the code worked so management wouldn't let me change it. I tried my best to find an edge case it wouldn't handle but never could. So the code shipped.
I feel like there is/should be some kind of programming language design equivalent of this. If you wanted to make programmers basically incapable of writing correct programs, how would you do it?
Here's where I'd share examples and it wouldn't be funny and instead start a flamewar.
Sounds like a really terrible programmer! Too bad it at least seems to be sometimes pretty much the only way to go certain things when nobody else wants to.
May the gods have mercy on the soul of who'll maintain code using these... "techniques".
(I know because back in the days I've written things like this myself :) ..probably the curses whispered by those who've had to endure their progenitors are finally getting at me)
reply