FridgeMagnet
Administrator
We spotted a 350+ line switch/case statement recently, each of the cases of which was an if/then/elseif/elseif/etc with multiple duplications, sometimes right next to each other.I'm convinced that some people's brains simply aren't wired the right way to ever become competent programmers.
I used to have a member of my team who wrote the most truly awful code and no amount of explanation resulted in improvements. There was a company restructure and - thankfully - he was moved into someone else's team. However this meant we had to support applications he'd worked on.
One such application needed a small change which fell to me to do. I looked at the code: it was fucking diabolical.
One piece of code had to decide where to route a message. He'd managed to write something so appalling (many, many nested IF this ELSE that ELSE IF this OR that AND NOT, etc) it was actually a thing of terrible beauty. I was so impressed that I printed it - it completely filled a sheet of landscape A3.
I replaced it with a function which was:
if A return X
if B return Y
return Z
Just. Three. Lines.
In a React component.
This was written by the team that now tells everyone else what to do.
