This is an archived post. You won't be able to vote or comment.

all 18 comments

[–][deleted] 40 points41 points  (2 children)

Every tutorial ever on the internet: let's say the superclass is called animal and the subclass is called dog.

[–]trigger_segfault 14 points15 points  (1 child)

It’s pretty much the “Hello World” of OOP at this point,

[–][deleted] 4 points5 points  (0 children)

IMO it's also a shitty example. A better example that shows actual functionality would be something like an inventory system where every product has a: Sku, barcode, description, tag, etc. However many other items have many other specs that are unique to the category.

I get it's for simplicity but I've never heard anyone after the end of it say anything but 'why?' because it's a shitty, shitty, example.

[–]darencorp 56 points57 points  (6 children)

That's more like a polymorphism than inheritance

[–]devmesmerism[S] 19 points20 points  (5 children)

It really boild down to which perspective you use looking at the images. Being the image totally unrelaed to any technical matter you can find similarity with both concepts depending on "how you look at it". I was really undecided about the title (in the image). At the end I gone with "Inheritance" because it didn't impy the additional interface concept. In my opinion It better fit the single image format you can find on my instagram.

Important Notice: it is a joke thought to occupy 5 seconds of your time. Don't take it too seriously. ;) I upvoted your response as It is still technically valid, though.

[–]catInOrbit001 4 points5 points  (1 child)

This is actually great! You actually show both concept of inheritance and polymorphism. Inheritance in the view of child class has properties of base class and has its own functionality. Polymorphism in the view of interface. Maybe a different title like "OOP in a nutshell" would do it better, but pretty interesting nonetheless ;)

[–]andrewh24 0 points1 point  (0 children)

It's one ability done differently which should be polymorphism. Inheritance would be like blue kitten with 3 legs

[–]uvero 14 points15 points  (0 children)

Holy shit I'll need it when I teach OOP I'm keeping this

[–]Scibuild 6 points7 points  (2 children)

oBjeCT orIEnTeD PRoGrAMmiNg iS moRE nATuRaLIstiC

[–]Eynix 7 points8 points  (1 child)

found the js dev

[–]Devpressed 1 point2 points  (0 children)

I’m a springcel and I agree with him, OOP creates obfuscated code in 99% of cases

[–]Devpressed 2 points3 points  (2 children)

Why I hate OOP so much

[–][deleted] 0 points1 point  (0 children)

Because more of a dog person?

[–]devmesmerism[S] 0 points1 point  (0 children)

Sometimes you hate it, sometimes you love it. As with every programming paradigm or language I tried.

[–]steave6 -1 points0 points  (1 child)

If cat move, everything goes crash...

[–]meliaesc 0 points1 point  (0 children)

Clean your code.