I make games

  • 0 Posts
  • 46 Comments
Joined 3 years ago
cake
Cake day: June 13th, 2023

help-circle



  • mozingo@lemmy.worldtoProgrammer Humor@programming.devWhat's a readability
    link
    fedilink
    English
    arrow-up
    10
    arrow-down
    1
    ·
    edit-2
    2 months ago

    Idk. Depends entirely on what kind of code you’re writing. Singletons are extremely useful patterns for video games, for example. There should never be multiple instances of classes that handle things like game state, achievement unlocking, display/resolution managing, etc.

    If they didn’t enforce their own singletonness then you’d have to always launch the game using the exact same startup routines, to ensure that only one of each ever gets instantiated. But game engines typically divide the game into something like “scenes”, which logically divide code and assets to only what’s relevant for that area of the game. When testing a specific level/area/scene, It’s extremely handy to have a singleton class exist in every scene, that acts as that startup routine, so you can start the game from any scene, and when you load in another scene through gameplay, the singleton class itself makes sure no duplicates exist, instead of having some kind of manager that keeps track of all that (which itself would also have to be a singleton, so you’d just be kicking the can down the road).



  • mozingo@lemmy.worldtoProgrammer Humor@programming.devWhat's a readability
    link
    fedilink
    English
    arrow-up
    27
    arrow-down
    1
    ·
    2 months ago

    I don’t get it. I literally write code that looks like both of these all the time. Null coalescing is cool, and very handy sometimes. In this particular case, I’d probably write it more like the left, since it’s more standard and my coworkers would be more familiar with it, but the right obviously does the same thing and I have no issues reading it.














  • mozingo@lemmy.worldtomemes@lemmy.worldA Game of Hangman
    link
    fedilink
    English
    arrow-up
    44
    ·
    10 months ago

    The image shows the hangman fully drawn, and dead. This means the player guessing letters lost. The header says that the parent lost. This means that the parent, a fully grown adult, looked at BI__IONAIRE and guessed a letter other than L. So when they said “I’m doing something right,” they must not have been talking about playing hangman lmao