• LCrawford (unregistered)

    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.

  • Prime Mover (unregistered) in reply to LCrawford

    You're not the only one.

  • RussellWakely (google) in reply to LCrawford

    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); });

  • (nodebb)

    Could this be a simple for (I=0;i<61;i++){ list.deleteColumn(0); };

  • (nodebb) in reply to Dlareg

    We don't know that list is a linked list - or more specifically, that the columns in list 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.

  • 516052 (unregistered)

    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

  • mark (unregistered) in reply to Eric Ray

    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).

  • Just another Embedded Designer (unregistered)

    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.

  • Steve (unregistered)

    Maybe the original programmer's performance was measured by lines of code. It used to happen.

  • Scott (unregistered) in reply to Steve

    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.

  • Argle (unregistered)

    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."

  • Sole Purpose Of Visit (unregistered) in reply to Steve

    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 ...

  • MaxiTB (unregistered)

    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.

  • a cow (not a robot) (unregistered) in reply to Sole Purpose Of Visit

    Hallo! How are the things going in Kerblekistan?

  • Coded the Dickens out of that Program (unregistered) in reply to MaxiTB

    It was the shortest of code, it was the longest of code...

  • rashmi (unregistered)

    Nice article

  • Barf4Eva (unregistered) in reply to Argle

    For some reason.... I don't like that things happen "for some reason"...

  • Steve (unregistered)

    The programmer had probably just finished reading about optimization by loop unrolling - and only then realized what it could do for his LoC count...

  • (nodebb) in reply to Sole Purpose Of Visit

    There is an other reason you can be fired (next to the thee you named). Touching a human without prior approval of that human.

  • Jeremy (unregistered)

    Why does a list have colums?

    What am I missing here?

  • eric bloedow (unregistered)

    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.

  • (nodebb) in reply to Dlareg

    Touching a human without prior approval of that human.

    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.

  • (nodebb)

    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]

  • (nodebb) in reply to Jeremy

    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

  • SemRnd14159 (unregistered) in reply to konnichimade

    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.

Leave a comment on “Delete Column From List”

Log In or post as a guest

Replying to comment #536177:

« Return to Article