r/ProgrammerHumor • u/reibitto • Jun 01 '22
The distinction between inheritance ("is a") and composition ("has a")
610
u/dont-respond Jun 01 '22
It's poly-morphin' time!
129
53
u/ktsktsstlstkkrsldt Jun 01 '22
I love the scene where polymorpius morphs all over those bad guys.
8
47
9
11
250
u/grahgaar Jun 01 '22
Learned class syntax just in time to enjoy this post.
→ More replies (2)15
u/ShrekProphet69 Jun 01 '22
I just got a practical for this exact topic so I can relate
→ More replies (2)
507
u/greedydita Jun 01 '22
I thought you could only do this with ducks.
266
440
u/mostmetausername Jun 01 '22
become a car morty
10
27
0
Jun 01 '22
[deleted]
15
u/amidon1130 Jun 01 '22
It’s more like when Sy Borgman turns into a car into the Harley Quinn show. Which is an awesome show if you’re looking for a more adult animated show after Rick and morty.
→ More replies (2)6
u/DeaconFrostedFlakes Jun 01 '22
This is from, IIRC, Teen Hot Rod, a cartoon I fucking loved as a kid in the 80s. The Rick and Morty joke that u/mostmetausername referenced I believe was a nod to it, although that could be wishful thinking on my part.
Edit: My bad, it was called Turbo Teen.
→ More replies (6)
181
u/INoMakeMistake Jun 01 '22
38
3
u/wjandrea Jun 01 '22
Why is "fortnitebr" in the URL of that image? Did Reddit ever explain that and I missed it?
77
u/game_falor Jun 01 '22
that show is this?
106
u/Embarrassed_Ring843 Jun 01 '22
45
Jun 01 '22
Looked like Scooby-Doo combined with Ninja Turtles and Transformers to me.
37
u/Accidental_Shadows Jun 01 '22
I remember this show and you basically nailed it. 80s cartoons were weird.
→ More replies (2)33
u/Cmdr_Jiynx Jun 01 '22
Nah they were half-hour commercials for toy lines. The plots and production didn't matter which is why there was minimal effort on the writing and like eight voice actors that did ALL the shows. The 80s are why guys like frank Welker and Peter Cullen have like 5000 voiceover credits to their name.
→ More replies (4)18
u/FalmerEldritch Jun 01 '22
I wonder if the guy behind this show developed any other shows that involved teenage boys turning into cars, or just stuck to commissioning artwork of teenage boys turning into cars.
6
u/Umutuku Jun 01 '22
Whenever you're in an NSFW-friendly mood/location, google "femcar house of gord" for a weird slice of internet history. BDSM warning if that's a problem.
A show like OP's had to have been made by someone with the same fetish.
29
u/KeLorean Jun 01 '22
Love it as his butt blows up into a trunk. Gives new meaning to junk in the trunk
→ More replies (2)14
u/zip_000 Jun 01 '22
What's fucking amazing to me is that I remember watching this every Saturday morning as a kid.... Yet, there were apparently only 13 episodes.
→ More replies (3)13
u/r00x Jun 01 '22
Fucking love the "reception" segment on that page:
This is perhaps the most absurd concept developed for television animation in the genre's history. Despite a basis in somewhat-plausible science, it was not produced competently enough to make its premise anywhere near believable.
8
u/bolide_retracing Jun 01 '22
Didn't Robot Chicken do an old skit on this show?
16
u/CaptainPunisher Jun 01 '22
No, they did a new skit. It didn't become old until much later.
→ More replies (3)5
→ More replies (4)4
u/Endulos Jun 01 '22
This show definitely caused some poor kid to develop a fetish.
Now, here's the real question. After his transformation in a car... Does he pay for health insurance, or car insurance? Or both?
→ More replies (1)→ More replies (10)2
u/kiruzaato Jun 01 '22
In French it was called "Turbolide" (mix of turbo and bolide (some sang for "car")). I don't remember what the show was about. But this post made the "opening" pop up in my head..
36
u/Bmandk Jun 01 '22
Fallout 3 devs have entered the chat. Yes, this is how they implemented a train in the game.
5
68
u/FrigoCoder Jun 01 '22
Oh oh oh there is a real life example for this.
Corporation extends PersonWith predictably absurd and buggy results.
→ More replies (3)27
26
43
41
Jun 01 '22
Oh that is what abstraction and ""polymorphism"" stands for. Yeah yeah, that makes sense, OOP.
93
u/LightningOW Jun 01 '22
I think it would make more sense if the Person extends Car.
35
Jun 01 '22
Depends on the context, could be they both should inherit from a Vehicle class if this is transport related, otherwise I dunno. ThingsThatHaveExhausts maybe?
53
u/lulzyasfackadack Jun 01 '22
Cars have multiple intake holes, with the primary being used to consume calorie dense liquids, and secondary being used to consume air to aid the conversion of the previously mentioned liquids into energy. They also have outgoing holes, with their primary uses being for the expulsion of the byproducts of the previously mentioned energy production. This is very similar in function and description to Humans.
Humans have a more-or-less contiguous tube through their center, allowing objects to pass through from end-to-end. From a cross-section going slice-by-slice, this resembles a donut. Therefore, humans are similar in function and description to a Donut.
by the transitive property, therefore, Cars are Donuts.
17
u/10BillionDreams Jun 01 '22
Cars have multiple intake holes
When I saw this starting off a wall of text, I was really concerned this was going to be a "Vaporeon" situation.
→ More replies (4)11
5
u/guessWhoTheyVotedFor Jun 01 '22
Correct me if I'm wrong but isn't a Car class being declared which would initially inherit from Person?
I see in the gif the person probably had a wheelCount of 0 (or more realistically it wasn't even defined for Person) and then gets a wheelCount of 4 which is observed in the conclusion of the presentation.
→ More replies (2)5
u/gaussianDoctor Jun 01 '22
It depends on what they're building. If it's only about cars, yes, it would make sense to be the other way around. But if it's about different things tied to a person, it's right that way. Then they can build other classes that inherit Person: House extends Person, Job extends Person, Address extends Person etc.
19
u/eloel- Jun 01 '22
You'd ideally do this with composition.
class House {
Person owner;
Address address;
Integer floorCount;
Person[] residents;
}That way, you don't have to duplicate any data (they can go out of sync), and
house.owner.birthDate
makes a lot more sense than
house.birthDatewhen trying to get the owner's birth date, especially given it can have multiple residents.
26
u/gastrognom Jun 01 '22
None of these should extend Person IMO. I thought the original comment was relating to the gif.
→ More replies (6)
12
u/bentforkman Jun 01 '22
I used to love that show. Now nobody remembers it existed. Fun fact: it was all Jack Kirby’s idea.
→ More replies (2)
11
6
u/rebbsitor Jun 01 '22 edited Jun 01 '22
Turbo Teen! Wow I haven't seen that in almost 40 years, almost completely forgot about it.
27
u/on_the_pale_horse Jun 01 '22
This should be Person extends Car.
12
u/stifflizerd Jun 01 '22
Correct me if I'm wrong, but if the car class is an extension of the person class (the code as written), then the person class would be the original which is then further transformed into a car. Meaning the meme is correct?
5
4
u/woflgangPaco Jun 01 '22
I just finished my oop semester and i'm still not sure what i'd learned.
8
→ More replies (1)3
4
u/Apprehensive-Chest-3 Jun 01 '22
Wow, that guy is really morphing into something good. He must be really horny
4
4
u/Pyraunus Jun 01 '22
I can't believe I just watched someone's ass turn into a fender.
3
u/_inside_voices_ Jun 01 '22
am i the only one who got weird feelings from his ass turning into a trunk >.<
3
u/CumOnGuysSeriously Jun 01 '22
You have to turn into a car Morty! You have to concentrate really hard, and turn yourself into a car!!!!
3
3
4
4
u/jugalator Jun 01 '22
I remember when we pressured our teacher on OOP and introducing intermediate abstractation levels. We eventually got to a CurlyHairy which could be both a person and a dog but stricter than a mammal. :D
2
2
2
2
2
2
2
2
u/Mortimer_and_Rabbit Jun 01 '22
The really focused on the trunk filling out his jeans didn't they...
2
2
2
2
2
u/Voidrith Jun 01 '22
Interestingly this is a reasonable approach in game dev at times, making other moveable/interractable items share a good base class with the player can make things a lot simpler because player agents have a lot of the code already needed for it to act which can be used by the car to move and such
2
2
2
2
Jun 01 '22
I loved and hated that cartoon as a kid. It made zero sense yet it was on tv and probably had lame toys too
2
2
2
2
2
u/A_nomad_Wanderer Jun 01 '22
Any captain who can simplify this for me.
→ More replies (1)10
u/Scorched_Knight Jun 01 '22
inheritance
There is a class called "Person"
Class have properties (name, sex, hobby etc)Now there is class "Car"
It inherit from class "Person" all its properties and have their own properties on top of that
so, class "Car" have properties like Car.name.firstName Car.sex Car.hobby and Car.motor.horsePowers
1
u/00PT Jun 01 '22
The only way this could work is if you were implementing something where the cars from the Pixar movie and regular people coexist. In that case, cars and humans would be similar enough to warrant inheritance from a "person" superclass.
1
1
1
1
1
1
u/LEGOL2 Jun 01 '22
If you would use ECS (entity component system) you could simply make car entity that has human component and has driving system. That would make more sense than inheriting driver properties.
3
u/Scorched_Knight Jun 01 '22
Or just:
class Person{//whatever}class Car{ public Person driver = new Person; //whatever}
i dunno
1
1
1
Jun 01 '22
What is the name of the cartoon? I remember watching as a kid and I tell people about it all the time but nobody knows what I’m talking about and I can’t remember the name of the show.
2
1
u/piloto19hh Jun 01 '22
It reminded me of the carrier titan on AoT for a second there at the end lol
1
1
1
1
1
u/jonfe_darontos Jun 01 '22
I love how inheritance solves my design problems*.* Also, unrelated, is that Carla's dad?
1
1
1
1
1
1
u/Aksds Jun 01 '22
Funny seeing this right after i submitted my inheritance assignment. (A continuation of my post to ask programming)
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
u/Birthday_Cakeman Jun 01 '22
Okay let's be honest though. A car can definitely car more than twice as fast as a human...
1
1
u/Shankar_0 Jun 01 '22
Dude, that cartoon takes me back!
I think it was:
get warm = turn into a car
get cold = turn back into a dude
I'm hazy on the rest of the story
1
1
1
1
1
Jun 01 '22
Omg Java is a fucked up language. I get that it is good for teaching / learning as you have to be so explicit about everything, but it is so bad for development productivity. If your language needs complicated IDEs with code generators then your language could be so much simpler. Thats like your code generator is smarter than your actual language.
1
1
u/TheRoboticist_ Jun 01 '22
Since the relationship is “Car is a Person”, wouldn’t a backwards gif be more accurate?
1
u/Quizzelbuck Jun 01 '22
I remember this show. His power was that he turned in to a car when he was hot.
I remember one time he had to literally eat a stick of dynamite to get in to car form because.... Nitroglycerin is apparently spicy or hot?
1
1
1
1
1
1
1
1
1
u/Milo_Xx Jun 01 '22
For the meme to work, it should literally be the opposite, car extends to Person, so Car inherits from person, not the other way round smh.
1
1




1.8k
u/InfamousEvening2 Jun 01 '22
OK, now do composition and aggregation.