kuuhana
  • Communities
  • Multi-communities
  • Support Lemmy
  • Search
  • Login
  • Sign Up
Programmer Humor@programming.devbybeep@piefed.world
1 day

When you delete a block of code that you thought was useless

English

cross-posted from: https://piefed.world/c/shit/p/1220170/when-you-delete-a-block-of-code-that-you-thought-was-useless

GIF Mirrors
  • https://img2.joyreactor.cc/pics/comment/it-юмор-2807906.gif
  • https://i.ibb.co/PvCKk6pq/1000032398.gif
  • https://galeri14.uludagsozluk.com/896/pembe-panter_1525876.gif
  • https://i.pinimg.com/originals/c8/df/e9/c8dfe9760923ac29472eaa021b18c608.gif
5
    You must log in or register to comment.

    • Quetzalcutlass@lemmy.worldEnglish
      1 day

      This is why I love the “find usages” inspection, though the IDE (at least JetBrains ones) will usually preemptively warn you about unused methods and functions.

      If it’s a block of logic in the middle of a function that you suspect is no longer needed, set a breakpoint in it and run the program before deleting it just to make sure it’s not being triggered.

        • ryannathans@aussie.zone
          1 day

          Deeper down the rabbit hole, more dangerous “useless” blocks of code won’t be found with “find usages” because the usage either:

          1. isn’t in the project, and is external. Like a powershell script calling a function present in the DLL, or your system’s equivalent. Or even hardware accessing it directly at a known address, like an IRQ table

          2. is accessed via reflection, which the IDE won’t know about

          3. for bonus points, the linker depends on it to make a functioning binary. Or some other dodgy code may break at runtime if offset from its original location in the binary…

        • Omega_Jimes@lemmy.ca
          1 day

          That’s why we comment first, then use version controls. Also we never test in prod.

          ROFL yeah right!

          • printf("%s", name);@piefed.blahaj.zoneEnglish
            1 day

            Fortunately:

            1. I quit the editor without saving the changes
            2. I have a previous version that still contains the block in question
            3. I have a few onions on which I can blame my tears
            • Hayduke@lemmy.world
              1 day

              Oof, just did that a couple of days ago, in prod no less (not able to test particular change in lower envs). Good times.

              Programmer Humor@programming.dev

              programmer_humor@programming.dev

              Subscribe from remote instance

              Create post

              Report community

              Modlog
              You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

              Welcome to Programmer Humor!

              This is a place where you can post jokes, memes, humor, etc. related to programming!

              For sharing awful code theres also Programming Horror.

              Rules

              • Keep content in english
              • No advertisements
              • Posts must be related to programming or programmer topics
              Visibility: Public

              This community is visible to everyone.

              • 452 users / Day
              • 2.65K users / Week
              • 2.71K users / Month
              • 14.7K users / 6 months
              • 2.35K posts
              • 90K comments
              • 2 local subscribers
              • 31.9K subscribers
              • UI: 1.0.0-beta.0
              • BE: 1.0.0-alpha.20
              • Modlog
              • Instances
              • Docs
              • Code
              • join-lemmy.org