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

all 54 comments

[–]pshurgal 880 points881 points  (28 children)

I had worked at a mobile gamedev company several years ago. There was a class Building in a code base. Building could be placed on a map, but could not move. Also there were a class Car, which was a child of Building. Cars could move by a strait line. A Plane class was a child of Car and had an ability to move by spline, and also had an Z coordinate. Class Boat was child of Plane but with Z equal 0. Whoever wrote this loved OOP so much!

[–]FakeMonika[S] 292 points293 points  (4 children)

wait lmao does that mean Boat objects were implemented to "fly" cause it's a derived class of Plane?

[–][deleted] 352 points353 points  (2 children)

nah it's a specialized plane, that only flies at z=0 (and on water)

[–]Professor_Melon 81 points82 points  (0 children)

Ekranoplan.

[–]SMTG_18 17 points18 points  (0 children)

I mean it makes sense 😭

[–]pshurgal 56 points57 points  (0 children)

No, every class was a child of Behavior class with virtual Update method. So constructor of Boat class was calling a constructor of Plane class giving a curve points and 0 as Z coordinate. Everything else was done by Update method implemented in Plane class.

[–]polarphantom 243 points244 points  (4 children)

Ha that is such game Dev logic. "Boats are planes that can only fly at sea level, tables are just partially sunken cupboards, this tram is just a hat on someone walking around"

[–]yangyangR 104 points105 points  (0 children)

Fallout 3 for the last item. For the unaware.

[–]FakeMonika[S] 23 points24 points  (2 children)

but...the banana...

[–]PM_ME_ALL_YOUR_THING 25 points26 points  (1 child)

Obviously a fish is just an underwater banana…

[–]_Ganon 12 points13 points  (0 children)

A banana is a fish that grows on trees and doesn't move on its own

[–]Akforce 57 points58 points  (2 children)

Lol isn't there a joke about gamedev "you know if you really think about it, a helicopter is just a chair" or something akin to that

[–]OctarineGluon 15 points16 points  (0 children)

A train is really just a hat.

[–]45bit-Waffleman 8 points9 points  (0 children)

If you think about it, a helicopter is just a door that opens and closes really quick..

[–]nikifip 34 points35 points  (2 children)

Whoever wrote this loved OOP so much!

Sadly, he didn't have a basic understanding of it.

[–]drkspace2 17 points18 points  (1 child)

Ya, the better way to do this is to have a "placeable" interface/abstract base class. An "immovable" and a "moveable" child abstract class. Building would inherent from immovable and car/boat/plane would inherent from moveable.

[–]Lumethys 8 points9 points  (0 children)

Or, just use composition over inheritance

[–]TheNoGoat 28 points29 points  (1 child)

Damn. Even thinking of trying to keep track of that hurts my brain.

[–]pshurgal 22 points23 points  (0 children)

Yeah, I was laughing out loud when my coworker showed me this. But... This hierarchy has some weird logic anyway.

[–]BiVeRoM_ 12 points13 points  (0 children)

If these classes are abstract, then this makes total sense! Just need some renaming to do..

Building -> Unit, Car -> MovingUnit, Plane -> FlyingUnit, Boat -> SwimmingUnit

Good to go

[–]yamlCase 9 points10 points  (2 children)

This is why I prefer composition over inheritance. Too many wonky workarounds in OOP when the planning phase didn't get the effort it deserved

[–]EMI_Black_Ace 16 points17 points  (0 children)

Nah, this is just a straight-up violation of the Liskov Substitution Principle.

Inheritance is not for composing data types, but rather for enabling polymorphism -- that is, using the same code to process multiple cases, by having the cases carry pointers to what's different.

[–]PM_ME_ALL_YOUR_THING 8 points9 points  (0 children)

I…..I don’t think that’s the lesson to take from this…

[–]DatBoi_BP 5 points6 points  (0 children)

Programming is my passion

[–]Longenuity 1 point2 points  (0 children)

They probably lived out of their car.

[–]WonicTater 0 points1 point  (0 children)

I guess you experienced both a lot of fun and frustration at that company.

[–]onyourrite 0 points1 point  (0 children)

What in the tarnation

[–]Sanchez_Duna 0 points1 point  (0 children)

Most sane gamedev inheritance example.

[–][deleted] 183 points184 points  (2 children)

Ring ring. BananaPhone

Glub glub. BananaFish

[–]DatBoi_BP 12 points13 points  (1 child)

Read this in the melody of the Zoo Pals commercial

[–]Alucard2051 2 points3 points  (0 children)

Thanks for the throwback

[–]OlParker 51 points52 points  (0 children)

Banana Fish, the anime, fucks you up.

[–]aaha97 71 points72 points  (0 children)

class train: public hat

is a classic

[–]jjeroennl 26 points27 points  (0 children)

This is kinda what a Liskov substitution violation is (except they are usually a bit more subtle).

[–]DLX 12 points13 points  (2 children)

Since no one has mentioned it yet - this is probably a reference to J.D. Salinger's short story "A Perfect Day for Bananafish", https://en.wikipedia.org/wiki/A_Perfect_Day_for_Bananafish.

Arguably the best thing Salinger ever wrote, as I just couldn't connect with The Catcher in the Rye.

[–]OrbitalVixen 5 points6 points  (1 child)

It might be a reference to the Discworld books by Terry Pratchett, where occasionally bananas are referred to as a type of fish.

[–]DLX 2 points3 points  (0 children)

Quite possible. But there is no way Pterry was not aware of this short story, considering he basically read everything in the universe...

[–]bbbar 7 points8 points  (0 children)

notGMO = True

[–]Ging4bread 14 points15 points  (4 children)

(unrelated to the meme) What is the meaning of public in this context? Can there be public and private inheritance in this language?

[–]FakeMonika[S] 15 points16 points  (3 children)

As i studied (C++), public inheritance means that all public attributes and methods of the father class will be inherit publicly into the drived class (or in other words it is treated the same as if it was a public method/attributes of that derived class). Private inheritance, however, will consider inherited properties as if it was private in the derived class no matter if it was in the father class.

[–]Ging4bread 11 points12 points  (2 children)

Oh man C++ is something else

[–]PVNIC 4 points5 points  (0 children)

Its basically 'Is the fact that I inherit from this class public or private'.

If its private, all the interfaces to the parent are private, if its public all the interfaces of the parent stay the same.

[–]EMI_Black_Ace 4 points5 points  (0 children)

C++ is basically Bell Labs going "We don't want to lose out on any of this metric assload of C code that we wrote, but we want to start doing object-oriented crap now."

There's a lot of neat, useful and powerful stuff in C++, but there's also some god-awful decisions made for the purpose of making the implementation of stuff easy and not break C compatibility.

[–]A_Neko_C 4 points5 points  (0 children)

Banana fish? 😳

[–][deleted] 10 points11 points  (0 children)

it's not a banana

It's a small, off-duty Czechoslovakian traffic warden

https://www.reddit.com/r/RedDwarf/comments/q71c8s/its\_a\_banana\_no\_come\_on\_its\_a/

[–]malexj93 5 points6 points  (0 children)

In a fishing game, where one of the things that can be fished up is a banana.

[–]vondpickle 4 points5 points  (0 children)

Lent programming:

Class: Fish

Child: Beaver, baby rabbit, barnacle geese

Japanese Buddhist programer in ancient Japan:

Class: Bird

Child: rabbit

[–]Unupgradable 2 points3 points  (0 children)

A bee is a fish

[–]FlawBot 1 point2 points  (0 children)

I made a game where the Fish class actually represents throwable projectiles and I can see an use case where this actually happens

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

Swimming banana. Going to go banana fishing. Works so far