• (nodebb)

    Well.... it might throw an exception if one of those properties doesn't exist...

  • (nodebb)

    Hey, the word function was spelled correctly!!

  • (nodebb)

    This looks like debugging code, someplace you could put a breakpoint in...

  • (nodebb) in reply to Medinoc

    Yes - I'd definitely put this one down to "this is where we put the debug statement when something is broken".

  • Robin (unregistered)

    Hey, at least it has descriptive names for the arguments... oh hang on.

    Arguably even worse is that these arguments are clearly expected to be arrays yet have an additional string key called "condition". Arrays having any such non-numeric key (apart from the built-in and obviously useful "length") is a clear code smell as far as I'm concerned. And yes I know this particular code does nothing, but I have to assume since these properties exist they must be used somewhere in this codebase.

  • LCrawford (unregistered)

    As a side effect, the function sets the global variable 'temp'.

  • (nodebb)

    The let keyword scopes the variable to the block it's contained within, so, nope.

  • (nodebb) in reply to LCrawford

    As a side effect, the function sets the global variable 'temp'.

    According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let :

    The let statement declares a block-scoped local variable, optionally initializing it to a value.

    Block-scoped, not global.

    https://www.w3schools.com/js/js_let.asp says much the same thing:

    Variables defined with let have Block Scope.

  • DrPepper (unregistered)

    It takes a full-time dev just to keep it running...

    1. Fire this full-time dev. He's clearly not doing his job well, because his job really should entail:
    2. Reorganize the filesystem, so that it's easier to work with (this is a zero-risk task, if using modern build systems like webpack)
    3. Start writing unit tests. This is also zero-risk (since writing tests do not require changes to the code); and should start identifying broken code.
    4. When a fix needs to be made, write tests for the file that is being fixed.

    It is amazing how people are willing to continue to work in crappy code bases when it's so easy to make the code less crappy.

  • Argle (unregistered) in reply to DrPepper

    Good idea... if programmers ran the place. I assure you that some manager there isn't going to let your plan go through.

  • WTFGuy (unregistered)

    Hah! But first you need to

    1. Persuade the PHB to ask for funding for a modern build system like webpack.
    2. Persuade the PHB's grandboss this has positive ROI for the company. etc. for about 50 steps. Then comes the big bang migration to webpack.

    Unit tests totally require changes to the code, IF that code is deeply coupled to everything and a few inner platforms and a massive collection of global state.

    etc.

    Which is not to say improvement cannot and should not be made. But it requires a business, not a dev shop, that recognizes that investing time and present dollars on this below-decks work for zero immediate ROI will in fact have positive ROI later. Also not to mention the interpersonal politics that every bit of that technical debt represents decisions made by people (probably now senior people) who may still be there and are not eager to have their body of work questioned or abandoned.

  • WTFGuy (unregistered)

    Oops. Just eaten by Argle.

  • Barry Margolin (github)

    This isn't even anciemt legacy code, as it uses the ES6 let keyword.

  • Yikes (unregistered)

    Smooth choice using 'let' instead of 'var' for the loop index...

  • Loren Pechtel (unregistered)

    Another vote for a debug trap. There's some problematic data condition this detects, put a breakpoint on it when you're hunting for what caused it this time.

  • reinventingTheWheel (unregistered)

    Perhaps there is a race condition present elsewhere in the code and this code is just trying to slow down a process to "hopefully" avoid the race condition... Otherwise, maybe someone is getting paid by the lines of code that they write.

  • (nodebb)

    This article has a side effect too, I learned about the mathematical use of ℵ. Cool.

    https://en.wiktionary.org/wiki/%E2%84%B5

  • Your Name (unregistered)

    Using debug statements for debugging. 50 years of programming have shown that good debugging utils are priceless. And yet, after 20 years of this shitshow of web dev they still don't have anything decent.

  • RussellWakely (google) in reply to Robin

    I don't think the input parameter ("varA") is an array (as access to its data is done through a field called "field"

    The signature for varA seems to be something like

    { length : number; condition:boolean|any; field : Record<string,any>[] | any[]; }

    Addendum 2022-06-07 04:39: That should be Record<string,any>[] | any[] [] (second array indicator got removed when by the commenting system?)

  • Xorium (unregistered) in reply to DrPepper

    All things you propose take time. And that seems to be the problem here

  • Behodar (unregistered)
    Comment held for moderation.
  • Open plots for sale in Shadnagar (unregistered)
    Comment held for moderation.
  • Kythyria (unregistered) in reply to Your Name
    Comment held for moderation.
  • Kythyria (unregistered) in reply to Your Name

    Oh yes, and there are perfectly good debuggers built right into browsers. Have been for a big chunk of that 20 years (and as extensions/external tools before that).

Leave a comment on “onFunctionCall”

Log In or post as a guest

Replying to comment #563660:

« Return to Article