Open Menu
AllLocalCommunitiesAbout
lotide
AllLocalCommunitiesAbout
Login

monumentale

⁨235⁩ ⁨likes⁩

Submitted ⁨⁨11⁩ ⁨hours⁩ ago⁩ by ⁨not_IO@lemmy.blahaj.zone⁩ to ⁨[deleted]⁩

https://lemmy.blahaj.zone/pictrs/image/deccf35f-4588-4e0b-b600-ba3a812d7820.webp

source

Comments

Sort:hotnewtop
  • kryptonianCodeMonkey@lemmy.world ⁨3⁩ ⁨hours⁩ ago

    When I was in my 101 comp sci classes, one of my professors would say, “A function is meant to do one thing. So if your function doesn’t fit on the monitor in it’s entirety, that is a good indication your function is probably too complicated and/or doing too many things. Either simplify it or break it down further.” And that’s a rule I usually try to live by with my professional work too. So, anyway… I want to see the 4000k monitor this guy is using.

    source
    • Gonzako@lemmy.world ⁨1⁩ ⁨hour⁩ ago

      I personally go by the monocre that if it’s something important, it’d be all on one file as not to lose the train of thought when debugging it.

      As jumping around between files

      tends to break up thought lines

      also, the compiler likes it better when there’s layers

      source
      • LodeMike@lemmy.today ⁨1⁩ ⁨hour⁩ ago

        The compiler can get fucked

        source
  • TheWonderfool@lemmy.world ⁨10⁩ ⁨hours⁩ ago

    And what’s beautiful is that the one right under has a comment “we don’t use thi…”

    This code looks like so much fun to debug…

    source
    • niartenyaw@midwest.social ⁨9⁩ ⁨hours⁩ ago

      i like to imagine it says

      we don’t use this, but if you delete it everything in this file breaks

      source
      • Taldan@lemmy.world ⁨7⁩ ⁨hours⁩ ago

        we don’t use this without first writing proper unit tests for our changes, integrating them with the regression tests, and thoroughly documenting our changes for the next developer that has to work on this

        I’m an optimist, and it’s technically possible

        source
        • -> View More Comments
    • Blackmist@feddit.uk ⁨7⁩ ⁨hours⁩ ago

      There’s one I found today that just reads “this is a fucking abortion”

      I don’t remember doing it, but it was almost certainly me.

      source
  • zr0@lemmy.dbzer0.com ⁨10⁩ ⁨hours⁩ ago

    Is the function called is_even()?

    source
    • kryptonianCodeMonkey@lemmy.world ⁨3⁩ ⁨hours⁩ ago
      def is_even(num:int) -> bool:
          if x < 0:
              x = x * (-1)
          if x == 0:
              return True
          elif x == 1:
              return False
          elif x == 2:
              return True
          elif x == 3:
              return False
          elif x == 4:
              return True
          elif x == 5:
              return False
          elif x == 6:
              return True
          elif x == 7:
              return False
      # ...
      
      source
    • Taldan@lemmy.world ⁨7⁩ ⁨hours⁩ ago

      Yes, and it only returns, “I can’t even”

      source
    • railwhale@lemmy.nz ⁨7⁩ ⁨hours⁩ ago

      Here, I optimised it:

      private function is_even(integer): 
          integer = 2;
          return True;
      
      source
  • Gladaed@feddit.org ⁨10⁩ ⁨hours⁩ ago

    That’s just some hard coded lookup table. Nothing to see here.

    source
    • Diplomjodler3@lemmy.world ⁨10⁩ ⁨hours⁩ ago

      It’s the lookup table for odd and even numbers.

      source
      • boonhet@sopuli.xyz ⁨9⁩ ⁨hours⁩ ago

        Needs a few more lines

        source
        • -> View More Comments
  • abbadon420@sh.itjust.works ⁨11⁩ ⁨hours⁩ ago

    Holy mother of functions

    source
  • ChaoticNeutralCzech@feddit.org ⁨9⁩ ⁨hours⁩ ago

    Cannot be expanded, it’s private. Proprietary blob.

    source
  • vane@lemmy.world ⁨3⁩ ⁨hours⁩ ago

    get date switch case

    source
  • Winter_Oven@piefed.social ⁨10⁩ ⁨hours⁩ ago

    imagine if the entire function is a single if-else statement which they kept adding onto, but could never refactor lest everything crashes down and burn.

    source
    • Daedskin@lemmy.zip ⁨9⁩ ⁨hours⁩ ago

      I once worked on a project doing firmware that a lot of people have likely used (printer firmware for a big-name company). One of the more trafficked functions was something like 1500 lines of “if-elseif-elseif…” with something like 13 or 14 different cases.
      It did end up getting refactored to something polymorphic and based on a configuration file to cut out any unnecessary steps, but it was like that for a while before I got there, and was like that for most of the year that I was part of the project.

      source
    • JargonWagon@lemmy.world ⁨3⁩ ⁨hours⁩ ago

      4k+ nested if statements with comments.

      source
  • folekaule@lemmy.world ⁨10⁩ ⁨hours⁩ ago

    Those lines are mostly comments, right? Right?

    source
    • kibiz0r@midwest.social ⁨7⁩ ⁨hours⁩ ago

      Yeah, just comments… with chapters…

      source
      • Thorry@feddit.org ⁨6⁩ ⁨hours⁩ ago

        // - - - - - - - - - - - - - - - - - -

        // Note added by employee 871 - S. Sandler - 10-31-2003

        // Chapter 1

        // Dear reader, let me tell you all about this here function.

        // You see it was a dark and rainy night, like the nights often were in the place I once called my home.

        // My grandma used to tell stories about those nights, the nights where the cold creeps in and the fog rises up from all around.

        // She used to tell us those nights were haunted, evil things happened which could not stand the light of day.

        // I never put much stock into those stories, but when the rain beat against the window and the wind would rustle the trees, I figure she might have been onto something.

        // So you see it was one of these typical nights where I learned evil does indeed come out. But not from outside as one might expect, no… The evil comes from within

        // Chapter 2

        // Just like every other Friday, I got stuck with night duty. I wanted to go drinking with friends, but my manager told me I needed the extra shift since quarterly reviews were coming up.

        // I was in a faul mood and cursed my manager, but like my grandma used to say curses can be a dangerous thing. They have a tendency to backfire when not used in moderation.

        // Frankly I’m not sure my grandma knew what moderation meant, otherwise she would have cut down on the amount of beans she ate.

        // Let me tell you; old folk and beans aren’t a great combination. But I digress.

        // Getting stuck with night duty wasn’t bad, it didn’t pay much, but you could work from home and usually nothing much happened, especially on a Friday.

        // So I sat around watching some old X-Files episodes, keeping half an eye on my mailbox to see if any tickets came in. I do say that Scully chick is one hot mamajama, I kinda forgot about the story.

        // It was at this moment I heard loud thunder rolling by and the familiar wee-woo sound of my email client getting a new mail.

        // As I read the ticket number: EI-WA-98215-6-66 the hair on the back of my neck stood up.

        // Chapter 3

        // I wondered who could be submitting tickets at this hour, but it must be important so with one eye on Scully I checked out the ticket.

        // For some reason the user name wasn’t in the ticket, just the user number. I had complained about this to IT and they said they would “get to it” whatever that means.

        // I swear to the gods if you think developers have their own code to make fun of users, IT guys are way worse. They probably just sit around crimping their cables or whatever they do.

        // Anyway this ticket was really weird, the user said when they opened up the admin portal the menu would freak out.

        // They said, I kid you not: “The menu is haunted and we need an exorcism”

        // Must be some kind of joker who also got stuck with the night shift and doesn’t have anything to do, so let’s mess with the poor devs right?

        // Chapter 4

        // When I opened up the admin portal I didn’t see anything weird at first, this dude was messing with me for sure.

        // I got hungry so I wanted to make myself a quick snack, I found a buldak ramen packet in the kitchen.

        // Perhaps I shouldn’t have judged my grandma for eating beans, as I know these spicy ramen will be much worse.

        // While waiting for the water to boil, I saw movement from the corner of my eyes, it was like there was someone in the room with me.

        // When I walked over to investigate it was suddenly gone, but I saw on my screen the menu was freaking out, opening and closing like crazy.

        // I turned to walk back to the kitchen and get my ramen going, but as I did suddenly I hear a loud bang in the apartment.

        // Chapter 5

        // As I investigated the noise I found a door had slammed shut due to the wind, I was pretty sure I had closed that door earlier…

        // With my snack in hand I went in to investigate the code running the menu.

        // After thorough investigation, I found no fault in the menu. The code hadn’t been touched in months and nobody had ever complained before.

        // But I had seen the menu misbehave myself, surely something must be wrong with it.

        // Suddenly it was like my hands had a mind of their own, they started writing code like I had never seen before.

        // With horror I saw what they were doing and I gasped. The only brief pause I got was when my hands turned to my ramen.

        // I felt sick by the code they had written, but they forced the spicy buldak into my mouth and when I refused to swallow, poured the lukewarm Mt. Dew in my mouth.

        // Chapter 6

        // Even though I have no explanation for the code that now lays before you, in order to clear my conscience I will briefly try to explain what it does.

        // My understanding isn’t complete, but what I’ve been able to glean from beyond the veil is the following:

        // Lines 8 - 26 deal with getting the user details, they appear to use the regular API for this but also some calls I’m not familiar with.

        // Lines 43 - 78 seem to get the users actual GPS coordinates, I have no idea how?

        // Around line 156 the weather.com API is used to get a current report at the users location.

        // The rest of the code seems to deal with various time and weather related checks. As far as I can tell it checks if it’s dark and stormy out.

        // In the last part of the function there is some simple logic that cancels the menu animation if it triggers too often.

        // Chapter 7

        // It was with a heavy heart I pushed commit 54D3AD into production with the simple message “Fixes ticket EI-WA-98215-6-66”

        // I went to close the ticket, but somehow I couldn’t find it in the ticket system anymore. Probably those IT guys messing up again.

        // The mail was gone as well, but with Microsoft Outlook that was pretty much par for the course, so I didn’t think anything of it.

        // Wanting to put this horrible experience behind me, I resumed watching X-Files, such a classic show.

        // A few minutes later my VLC crashed and kept looping on Mulder saying “Thank you”, but it was slowed down a bunch and distorted.

        // In the few seconds I needed to get my hand free from my sweatpants, all my power went out. We really should invest more into infrastructure…

        // - - - - - - - - - - - - - - - -

        // Note added by employee 2548 - Martin (intern) - 07-02-2009

        // New Weather.com API premium key added, no idea why we need this, but without it the menu breaks.

        // Could not find contact info for employee 871 - presumably left the company.

        source
        • -> View More Comments
  • SailorFuzz@lemmy.world ⁨9⁩ ⁨hours⁩ ago

    oh look, it’s the old codebase at my job

    Legit, the company banned people from using #region in their scripts because too many people were using it to hide massive amounts of slop code. Just giant fucking IF trees. Even though using it is hugely beneficial to keep things organized, especially if you use a lot of interfaces.

    source
  • owenfromcanada@lemmy.ca ⁨11⁩ ⁨hours⁩ ago

    I can smell it from here

    source
  • bacon_pdp@lemmy.world ⁨10⁩ ⁨hours⁩ ago

    One sheet of paper rule exists for a reason

    source