- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Frist to say that I scanned the sequences to see if there was a number out of order, omitted, or duplicated that would break the application when converted to the apparent algorithmic solution.
Admin
You're not the only one.
Admin
Even then, a saner solution is still something like
let idsToDelete = [65, 64, 63, 62, 60, 48, 47, 44 ];
idsToDelete.forEach(idToDelete => { list.deleteColumn(idToDelete); });
Admin
Could this be a simple for (I=0;i<61;i++){ list.deleteColumn(0); };
Admin
We don't know that
list
is a linked list - or more specifically, that the columns inlist
are a linked list. There could be a good reason for iterating in reverse order. For example, if deleting a column requires moving all subsequent columns, then deleting the highest index first will be faster.Addendum 2021-11-10 07:57: Of course, it's at least equally likely that the reverse order was simply the developer's way of coping with the idea that the indices change. I'm not saying there is a good reason. I'm just saying that there could be.
Admin
That's the fun with code like this. You newer know. And the time required to figure it out often exceeds your budget thus making it more affordable (from a management perspective) to leave it in until something breaks. sigh
Admin
Since it has Columns, list is likely a ListView (like Windows' Explorer's Details view), and it's a very good idea to remove them from last to first - if you have to remove them at all (no idea why you would).
Admin
Hmm unless columns 62+ exist, delete columns 0-61 inclusive is in reality delete whole list??? Depending on number of columns and overall size copy cols 62+ to new list iteratively or other effecient means then delete old list is more obvious to follow later
Sounds more like cut and paste grew over time and has a mantra add in one order delete in reverse order for some obscure old methodolgy reason.
Admin
Maybe the original programmer's performance was measured by lines of code. It used to happen.
Admin
Good point. The comment just says "aggressive optimizations enabled". We naturally assume the runtime performance is the object of the optimization but if they were trying to "optimize" their lines-of-code numbers that is a dandy way to do it.
Admin
In Chuck Sheppard's book "America's Least Competent Criminals" he has a footnote on the phrase "for some reason." He mentions that this phrase will appear in the book quite often. As in "for some reason, he wore a bag without eyeholes as a mask." In post-mortem discussions of code like this, people try to figure out "why." This first assumes that the programmer actually engaged in some kind of flawed thought process. Who is to say that any kind of thought process was involved, flawed or otherwise? It's just coded that way "for some reason."
Admin
Obviously the HR metrics changed drastically, in that case. Otherwise he/she wouldn't have been fired.
On a tangent, it seems to me that it's remarkably infrequent for a programmer to be fired -- largely because, if the PHBs don't have a clue what you're doing, they don't have the metrics to fire you (other than for gross impertinence, alcoholism, or being a Kerblekistan spy, of course).
Which makes me wonder why I've been fired four times ...
Admin
Most likely got paid by lines of code, or was considered a hero in the company because of his fast typing skills. We all meet someone like that sooner or later.
Admin
Hallo! How are the things going in Kerblekistan?
Admin
It was the shortest of code, it was the longest of code...
Admin
Nice article
Admin
For some reason.... I don't like that things happen "for some reason"...
Admin
The programmer had probably just finished reading about optimization by loop unrolling - and only then realized what it could do for his LoC count...
Admin
There is an other reason you can be fired (next to the thee you named). Touching a human without prior approval of that human.
Admin
Why does a list have colums?
What am I missing here?
Admin
reminds me of an older story: a stupid programer never heard of SUBROUTINES, so every time his program needed to validate date, he copied the entire validating process...BY HAND, since he also never heard of copy/paste! nobody realized it until his program started causing errors because he had made typos in those copys.
Admin
Even if "touching" means "feeding the [REDACTED] a knuckle sandwich". I was >< that close to doing that on one occasion, a useless [REDACTED] who decided that it was acceptable to amuse himself by making mock of my accent and my imperfect use of French. (I'm English, but the company is French and the office is in France, but even so ...)
Instead, I complained about his behaviour to our manager, and was told that I wasn't the first to complain about this dude. He was let go at the end of his probabtion period, mostly, I think, because of the "useless" part, although the "rude fucknut who enjoys picking on people on a basis of national origin" thing surely didn't help.
Admin
Multiple people have mentioned the "Why" (along with the unknowns from the code snippet). Capturing the "Why" (not necessarily directly in the code, but in something durable ad accessible is the #1 way to reduce lost "tribal knowledge"...
ps: I use a charting tool, where the columns are calculations based upon the (single) data item contained in the row. So deleting the columns (presuming there is not a columns.clear() in this way [not the explicit fall through, but meaning individually and in reverse order] may acetually be the right thing to do... [see previous paragraph]
Admin
Because it's a list of things that have columns! :)
Addendum 2021-11-11 15:59: Ah geeze, I totally skimmed over the fast that
DeleteColumn
is a method on the list itself. WTF indeed.Addendum 2021-11-11 16:00:
s/fast/fact
Admin
No addendum needed: the lists obviously have lengths that are a multiple of 62. To explain the "50,000 code lines" claim: only chapter 62 (out of +-316 chapters) was highlighted in the post.