Iterating across a list is a very simple task. It's a CS-101 type thing, and if anything, it's the one thing I'd expect any developer to be able to do without confusing me too much.
Brendan has a co-worker that wants to change my mind about this.
They write Java code like this:
if (counter == customerList.size() - 1 == false) break;
This is in the middle of a while loop.
counter is the iterator variable, which counts up from 0. So the real purpose of this
if is to check:
if (counter < customerList.size()), but obviously that's not what the developer chose to write here.
But it seems like they went out of their way to write the most cryptic version they could. A good ol'
!= would have been annoying, but also worked. They could have negated the whole condition. But no, they needed to compare two values and then compare the result of the compare to false.
It's just one line, though it was lifted from a file the style of which was very much in keeping with this exhibited spirit of disdain for maintenance. The author didn't hang round long enough to have to deal with this mess.
The developer who writes code like this didn't stick around long? I'm surprised they didn't get promoted to management. With skills like this, they could easily be the CEO of Twitter.
This post originally appeared on The Daily WTF.