• xmunk@sh.itjust.works
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    1 year ago

    If you’re in a language that supports it, please don’t use if (false) use if ($disallowAllUsers = false && $whateverTheRealConditionIs)

    • Kogasa@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      The assignment syntax is too close to comparison, which is what is more typical in that position. I would recommend

      const bool _isFeatureEnabled = false;
      if (_isFeatureEnabled && ...)
      

      if not a proper feature flag (or just remove the code).

  • katy ✨@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    bonus points if you use a different variable every file so they have to go through and change every instance if they want to make changes

  • asudox@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    1 year ago

    I don’t see the need for an if block or renaming the function and leaving it there. It is extra unnecessary work for the compiler. Comments are probably the best way. Might also copy the current file, put the original in some folder like “old”, and delete the old code inside the new copy.

    • dmrzl@programming.dev
      link
      fedilink
      arrow-up
      7
      ·
      edit-2
      1 year ago

      Comments are the worst as they are ignored by refactoring. That’s the reason if (false) is actually really good for temporarily disabled code.

    • frobeniusnorm@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      On a modern computer dead code analysis with constant folding should be nearly unnoticeable when compiling a large project