var Turtle1 var Turtle2 var Is_Turtle
Try assembly language! You have registers, and they are named for you with highly memorable names like R17.
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.
SHOUTING_SNAKE_CASE aka SCREAMING_SNAKE_CASE is the best case for all use cases, because it gives you a chance to use its wonderful names.
An array?
var turtles = new Turtle[] { new Turtle(), new Turtle() };
Don’t do this :P
Have you considered using inheritance?
Have you considered multiple inheritance. It’s an upgrade. All upside, literally no downside. I’m trustworthy. Trust me.
You might not like it, but that is what peak shareholders value looks like.
I’m an amateur I’m not sure what inheritance is:X? Is it like instantiateing?
When you start learning about different paradigms, you’ll likely learn much more about inheritance when learning about the Object Oriented design paradigm.
To overly simplify, you create objects that inherit attributes from other objects. It’s for instance a way to create reusable patterns, that have stronger and more reliable data structures.
I made the joke comment, because for instance, you could create a Turtle
class, and always know it was a Turtle
. Again, an oversimplification.
EDIT: I should also add that for some reason OOP is an oddly divisive subject. Developers always seem to want to argue about it.
At this point I think there is no software dev topic that is somehow not devisive.
Oh yea, class resources. That would work! Thanks.im going to have to into this more, as it’s going to be useful
Inheritance established “is a” relationship between classes.
class Turtle;
class TigerTurtle is a Turtle (but better);
class BossTurtle is a Turtle (but better);
Underlying classes hold an inner object to the super class, everything from Turtle will be in TigerTurtle and BossTurtle.
In some languages that is configurable with public, private, protected keywords.
Relatedly, there’s also composition, which establishes a “has a” relationship:
class TurtleTail;
class Turtle:
var tail: TurtleTail; (has a tail);
Since Turtle is NOT a tail, but a whole animal, turtle should not inherit TurtleTail. But it HAS a tail, thus we add turtle tail as a property.
I’m only commenting because the actual python is practically pseudo code:
# A turtle class
class Turtle:
shell=True
# A boss class
class Boss:
authority=True
#A class that inherits from another
class TigerTurtle(Turtle):
fuzzy=True
# Multiple inheritance, or "The Devil's Playground"
class TigerBossTurtle(TigerTurtle, Boss):
# shell, authority, and fuzzy are all true
...
Fucking mathematicians
What’s wrong with making a recursive function in a recursive function with variables M, m, N, n? It’s perfectly fine when I’m writing infinite series.
If we’re talking mathematicians, you just know it’s going to be ω-nested recursive functions any moment now. Just be grateful it’s not all n with polynomial subscripts or something.
Polynomial subscripts sound awesome, ngl. Never seen it before; I want to know what the applications are.