|
|
|
| Non-WTF Job: C++ Developer at Good Grievance (Ronkonkoma, NY) |
| « Application Lifecycle Mismanagement | Announcement: Alex Sells Out! » |
"At my workplace, we have a wiki for the 'WLC' — the Worst Line Competition," Kirk writes. "We post lines of code that the lead developers have decided were good additions to the applications that we port. Here is one of the better ones:"
patno -= ((((((((((((((((40+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+10)+1)+('Z'-'A'))+1)+1)+1);
Currently, this line is winning the Worst Line Competition.
For most of our submissions, I can tell what the developer was going for (and where he went wrong). Not this time, though. I've narrowed it down to two theories — either the developer's number keys other than 4, 1, and 0 were broken, or he was playing a future prank on some poor maintenance developer.
I've taken the liberty of making it more readable (and therefore more profitable if paid by the line) below. You're welcome.
patno -=
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
40 + 1 //41
)
+ 1 //42
)
+ 1 //43
)
+ 1 //44
)
+ 1 //45
)
+ 1 //46
)
+ 1 //47
)
+ 1 //48
)
+ 1 //49
)
+ 1 //50
)
+ 10 //60
)
+ 1 //61
)
+
(
'Z' - 'A' //86
)
)
+ 1 //87
)
+ 1 //88
)
+ 1 //89
);
Also, I should note that you may not use this code in your own applications. If you want to reduce a variable by 89, you'll have to find another way to do it.
|
LISP would have been better suited to this problem.
change patno -= ((((((((((((((((40+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+10)+1)+('Z'-'A'))+1)+1)+1); to (+(+(+(+(+(+(+(+(+(+(+(+(+(+(+(+(+ 40 1)1)1)1)1)1)1)1)1)1)1)10)1)(- Z A))1)1)1) now it's readable, and there's one more pair of ()! |
|
Possible explanations:
1. We've all seen code that doesn't make sense when you look at the finished product. But no one would ever just sit down and write it that way. These things EVOLVE over time! It was previously just patno -= (((((((((((((((40+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+10)+1)+('Z'-'A'))+1)+1); but the last programmer was told to add one to the existing algorithm. And so on. 2. He was testing the optimizing compiler. 3. This is actually documentation. If you just code "patno -= 89" the next guy is going to wonder "Why 89? Where'd that come from?" 4. Computer Science teacher gave an F to anyone who didn't explicitly declare the order of evaluation. |
If the brackets were the only thing there that you found weren't necessary, I'm glad you don't work with me. |
Re: A Dubious Honor
2008-06-20 09:23
•
by
Matt R
(unregistered)
|
Or *gasp* you could use a comment! Then you can remove the assumption that the moron who will be reading/maintaining your code will see the "obvious". final long ms = 300000; /* 5 minutes worth of milliseconds */ |
| « Application Lifecycle Mismanagement | Announcement: Alex Sells Out! » |