this post was submitted on 12 Sep 2024
288 points (96.5% liked)

Programmer Humor

19187 readers
1747 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

founded 1 year ago
MODERATORS
 

var Turtle1 var Turtle2 var Is_Turtle

you are viewing a single comment's thread
view the rest of the comments
[–] wesker@lemmy.sdf.org 9 points 1 week ago* (last edited 1 week ago) (2 children)

Have you considered using inheritance?

[–] metaStatic@kbin.earth 19 points 1 week ago (1 children)

blew my inheritance on hookers and blow, now what?

[–] _stranger_@lemmy.world 11 points 1 week ago* (last edited 1 week ago) (2 children)

Have you considered multiple inheritance. It's an upgrade. All upside, literally no downside. I'm trustworthy. Trust me.

Idunno, my mom told me not to talk to _stranger_s 🤔

... She said a lot of things that were BS, though, so maybe you're cool I guess? 🤷

[–] InternetCitizen2@lemmy.world 4 points 1 week ago (1 children)

You might not like it, but that is what peak shareholders value looks like.

[–] MajorHavoc@programming.dev 2 points 1 week ago (1 children)

Wow. "peak shareholder value" is what I shall now call "multiple inheritance", from now on.

[–] InternetCitizen2@lemmy.world 2 points 1 week ago

I like it. I'd let you serve as a CTO at my beloved corp

[–] OttoVonNoob@lemmy.ca 4 points 1 week ago (2 children)

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

[–] wesker@lemmy.sdf.org 6 points 1 week ago* (last edited 1 week ago) (2 children)

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.

[–] hoshikarakitaridia@lemmy.world 6 points 1 week ago (1 children)

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

[–] MajorHavoc@programming.dev 1 points 1 week ago (1 children)

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."

[–] hoshikarakitaridia@lemmy.world 2 points 1 week ago* (last edited 1 week ago) (1 children)

No one uses Boolean values anyway and with the amount of resources available on modern systems we can just replace them with integers and we should be fine. This also makes it easier to teach people, as they would learn less different data types.

Yes I'm a software dev :)

[–] OttoVonNoob@lemmy.ca 3 points 1 week ago (2 children)

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

[–] arendjr@programming.dev 3 points 1 week ago (1 children)

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.

[–] magic_lobster_party@fedia.io 1 points 1 week ago (1 children)

I like to mix between OOP and FP for different levels. OOP is great for higher architectural problems. FP is great for everything under it.

And yes, inheritance was a huge mistake. Just use composition and interfaces instead.

[–] arendjr@programming.dev 2 points 1 week ago* (last edited 1 week ago)

Yeah, I mix them too, although I apply quite a bit of functional techniques especially at the architectural level as well. OO I use mostly for dealing with I/O and other areas where statefulness cannot be avoided.

If you’re interested, I also wrote an in-depth blog where I touch on these topics: https://arendjr.nl/blog/2024/07/post-architecture-premature-abstraction-is-the-root-of-all-evil/

[–] wesker@lemmy.sdf.org 1 points 1 week ago* (last edited 1 week ago) (1 children)

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.

[–] OttoVonNoob@lemmy.ca 1 points 1 week ago

I'll check it out! I'm very casual and doing thus mostly as a passion/Fun project. But I love any direction thank you:)

[–] ma1w4re@lemm.ee 3 points 1 week ago* (last edited 1 week ago) (1 children)

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.

[–] _stranger_@lemmy.world 3 points 1 week ago* (last edited 1 week ago) (1 children)

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
    ...
[–] ma1w4re@lemm.ee 2 points 1 week ago

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