• PeriodicallyPedantic@lemmy.ca
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    No lie, after taking about 2 weeks of my first programming course in university, I did almost exactly this, trying to make a poker game.

    I hadn’t learned about objects, or functions, or even loops. Just one big method that had an if for every hand permutation.

    I hadn’t ever been exposed to programming before, and I loved it, but I knew nothing about it. Those were the only tools I had in my toolbox, and you know what they say about how when you only have a hammer everything looks like a nail.

    I’m a professional dev now, so I really hope I grew out of it lol

    • homura1650@lemm.ee
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      Back when I was learning, I made a flashcard program. It had a class that was essentially a constant array, so you could call get(int i), and it would return an object describing both sides of the card.

      How did I implement such a class you ask? First, I made a spreadsheet with 2 collumns to hold the data, with a third collumn of incrementing integers. Then, in the 4th column, I used string concatanation to right a java if statement that compared a variable against the index collumn; and if they match, return an object constructed from the 2 data columns.

      Click and drag the 1 cell I wrote in the 4th collumn to replicate it in all the rows, then copy and paste the 4th collumn into notepad++.

      I’d like to say I’ve moved past this; but my most successful projects have mostly been code generation ones; so really I’ve just moved past Excell.

      • luciferofastora@lemmy.zip
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        I mean, moving past Excel is still an excellent development.

        Signed, a guy that keeps dealing with people who need my code to spit out weird spreadsheets.

    • Researchgrant@lemmy.world
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      1 year ago

      It’s definitely satire. 2 million lines of code is an absurd under-exageration. This post had me looking up the number of possible chess games, because if you coded chess like above you would have to have an if statement for every outcome, and it’s 10^120 different possible games.

      https://en.wikipedia.org/wiki/Shannon_number

      • Taalen@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        The way I understood it, it’s two million lines and nowhere near finished.

        Anyway, satire.

      • PeriodicallyPedantic@lemmy.ca
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        1 year ago

        That’s the number of possible games, the number of possible board states is much lower, 10^40.

        Although you’re still clearly correct in the end anyways because it’s still an absurd number of board states and it’s not even formatted to be one state per line.

  • adONis@lemmy.world
    cake
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Lol… stupid junior-devs… in such case you should go with switch-statements instead… much cleaner.

    • Gumus@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      Switch-statement (called match) was added to Python 3.10 in late 2021. This is a reasonable, albeit older style of enumerated branching.

      • vithigar@lemmy.ca
        link
        fedilink
        arrow-up
        0
        arrow-down
        1
        ·
        1 year ago

        Switch statements and differently named but similarly purposed statements have been around since the 60s. Get outta here with this “switch is a newer style because python only just got them” nonsense.