• vacuumoftalent@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    Looks ugly until you need to implement something and realize you’ve been blessed with a description of business logic.

    • BeigeAgenda@lemmy.ca
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      Until they find out that the way to descriptive variables or functions needs to be extended with new business logic requiring renaming of functions again and again.

      I think maintaining code with this level of verbose naming, will be a pain over time. If they don’t let the naming slip, and then they could as well use cryptic 3 letter names.

  • hstde@feddit.de
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    This is something that can easily get refactored, because the purpose of alia the variables is right there in the name. This is way better that spending three days to try to figure out what the purpose of var1 is.

    • jballs@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      0
      ·
      3 months ago

      Nah, refactoring this would be a bitch. Your function name contains everything that happens in the function. Which means if you add something to it, you also have to change the name of the function. So CallThisWhenThePlayerTakesDamageAndIfThePlayerHealthIsLessThanZeroThenAlsoTheyDie would have to go to something like CallThisWhenThePlayerTakesDamageAndIfThePlayerHealthIsLessThanZeroThenAlsoTheyDieAndIncrementTheTotalDamageTakenCounter if you added something else.

  • JakenVeina@lemm.ee
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months ago

    I’ll take this over the more “classic” styles, when people seed to believe they were paying the compiler by the character.

  • warlaan@lemm.ee
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    3 months ago

    The real naming fail is calling the class “GameManager”, still my number one pet peeve. With a class name as vague as that you would have to add tons of information into the variable name. (Also the class name begs for unorganized code. I mean name one function or variable that you could not justify putting into the “GameManager” class. After all if it’s managing the game it could justifiably perform any process in the game and access any state in it.)

    Once you put the first bool into a class with a name like AccessibilitySettings, calling it something like HighContrast is completely sufficient.

    • Dragster39@feddit.de
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      With a class name as vague as that you would have to add tons of information into the variable name.

      Technically they did exactly that.

    • Snazz@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      Unity actually gives any class with the name GameManager a special gear icon. You cant just forgo the cool gear icon!

      (Its not too terrible from an organizational standpoint because most of the scripts are attached to game objects. MonoBehavior is a component of GameObject. For instance, you’d never have player movement in the GameManager class, you would put it in the component class attached to the player character GameObject.)

      • warlaan@lemm.ee
        link
        fedilink
        arrow-up
        0
        ·
        edit-2
        3 months ago

        you’d never have player movement in the GameManager class

        You want to bet? (Source: I teach game programming on a college level.)

        But yeah, your comment about the gear icon is sadly more true than people may realize. Game developers do questionable things. => Engine developers cater to people. => Students argue that if something is supported it can’t be that bad. Sometimes it feels like fighting windmills.

    • Meansalladknifehands@lemm.ee
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      We’ve all been guilty of these mistakes, naming stuff is hard, structuring your project is hard, learning the grains of a language takes time. But comments like these are golden nugets, some might read this and think “oh yeah, this makes sense” and rethink their whole methodology of naming and structure. You might have pushed someone reading your comment, to think more about these things.

    • dan@upvote.au
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      “Manager” classes often end up like “God classes”, just like how “Utils” classes end up with a bunch of random stuff in them.

  • toastal@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    I’m already annoyed by the end of public static final string that the variable name doesn’t even bother me in these sorts of langauages. All things should be public, static, & final, by default so they aren’t necessary to write. You should only have to write what unsafeties you are opting into.

    • warlaan@lemm.ee
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      You may enjoy having a look at F#. It says that it’s “functional first”, but I think a better description would be “an opinionated version of C#”.

      For example it doesn’t have a “const”-keyword. Instead it has a “mutable”-keyword, because everything is const by default.

  • MachineFab812@discuss.tchncs.de
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    When the variable name is the description that should be in the comments.

    Idea: Comments that automattically populate the end of any line a given variable is invoked on, including spelling out formulas from that line. ie: float y=mx+b // (cartesian y value)=(slope)(cartesian x value)+(cartisian y-intercept)

    “Duplicated” coments not actually in the file, but specified witt the creation of such variables and spread around by the code editor /IDE.

    • paholg@lemm.ee
      link
      fedilink
      English
      arrow-up
      0
      ·
      3 months ago

      Then, you could take those comments, and have the compiler use them to ensure you’re using the right variable in the right place. Oh wait, we just invented a type system.

  • danhab99@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    You forgot to declare custom primitive types. You cannot create a bool you gotta declare a DoubleYouDoubleYouDoubleYouDotLemmyGradDotML_Bool

  • CanadaPlus@lemmy.sdf.org
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    3 months ago

    Hot take, but the main problem with this is that you have to type variables or use them in larger expressions. Otherwise I like it.

    These would make a great mouseover text. I don’t know if there’s any standard way to support that. Actually, how come coding in non-plaintext formats never took off?