var Turtle1 var Turtle2 var Is_Turtle

  • Kojichan@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    5 days ago

    I remember an old mentor programmer I had who basically described his job as building an addition to an addition to an addition on a tree house built in a twig.

  • henfredemars@infosec.pub
    link
    fedilink
    English
    arrow-up
    4
    ·
    7 days ago

    Try assembly language! You have registers, and they are named for you with highly memorable names like R17.

  • parpol@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    7 days ago

    Yeah, a name should describe what it is or does, so if you have two turtles, and let’s say turtle1 wants to shit on turtle2’s lawn, you could name them shittingTurtle and victimTurtle. If the name alone tells you what its purpose is, that saves a lot of time for people looking at your code.

    Is_Turtle is not a bad variable name because it tells you it is a Boolean with “is” and that the Boolean tells you whether something is a turtle or not.

    Also, depending on the language, I suggest either camelCase or snake_case naming of variables. PascalCase is usually for defining classes or in case of C#, methods.