var Turtle1 var Turtle2 var Is_Turtle

You are viewing a single thread.
View all comments View context
4 points

I’m an amateur I’m not sure what inheritance is:X? Is it like instantiateing?

permalink
report
parent
reply
6 points
*

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.

permalink
report
parent
reply
7 points

At this point I think there is no software dev topic that is somehow not devisive.

permalink
report
parent
reply
1 point

At this point I think there is no software dev topic that is somehow not devisive.

Now I want to try something:

“Boolean variables don’t suck.”

permalink
report
parent
reply
3 points

Oh yea, class resources. That would work! Thanks.im going to have to into this more, as it’s going to be useful

permalink
report
parent
reply
3 points

Just keep in mind that inheritance is nowadays a very contested feature. Even most people still invested in object oriented programming recognise that in hindsight inheritance was mostly a mistake. The industry as a whole is also making a shift to move more towards functional programming, in which object orientation as a whole is taking more of a backseat and inheritance specifically is not even supported anymore. So yeah, take the chance to learn, but be cautious before going into any one direction too deeply.

permalink
report
parent
reply
2 points
*

If I could give a suggestion I wish I had gotten much earlier on in my education and career, it would be to really spend some time learning about the different paradigms, and their best use cases. You will likely ensure yourself a strong foundation in software architecture.

permalink
report
parent
reply
3 points
*

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.

permalink
report
parent
reply
3 points
*

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
    ...
permalink
report
parent
reply
2 points

It is simpler than my faulty memory remembers, time to learn python again 😁

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

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

Community stats

  • 7K

    Monthly active users

  • 730

    Posts

  • 11K

    Comments