this post was submitted on 12 Sep 2024
289 points (96.2% liked)
Programmer Humor
19623 readers
2 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Inheritance established "is a" relationship between classes.
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:
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:
It is simpler than my faulty memory remembers, time to learn python again 😁