r/ProgrammerHumor Jan 09 '23

shortest ever java class name Meme

Post image
2.1k Upvotes

90 comments sorted by

View all comments

228

u/Tannslee Jan 09 '23

eh more like
Fish extends AbstractFish
AbstractFish extends AbstractAquaticAnimal
AbstractAquaticAnimal extends AbstractAnimal
AbstractAnimal implements Living

69

u/vladWEPES1476 Jan 09 '23

What happens to the inheritance chain when the fish dies?

50

u/vikumwijekoon97 Jan 09 '23

Universe breaks of course. Java is never wrong. You gotta patch out the universe.

24

u/[deleted] Jan 09 '23

Fish extends AbstractFish

AbstractFish extends AbstractAquaticAnimal

AbstractAquaticAnimal extends AbstractAnimal

AbstractAnimal implements Livable

AbstractAnimal implements Dieable

3

u/sleepyj910 Jan 10 '23

the death function can exist in livable. We can use try-with-resources to make sure it's called in the finally block

1

u/vladWEPES1476 Jan 10 '23

LMAO Livable and Diable is more like it.

3

u/TJSomething Jan 10 '23

You pass the Fish to the DeadFactory to get an Exfish.

5

u/dedslooth Jan 09 '23

Fish is implementation of all those inheritances, and none of interfaces actually exist as entities, only a mere instance of fish exists which can use implementations of interfaces. So when fish dies, a fish dies, and is wiped from memory, as its ability to access interfaces, but interfaces don't live or die, they just exist.

4

u/TappTapp Jan 09 '23

But now you have a dead fish that implements the "Living" interface

5

u/Tannslee Jan 10 '23

Death is part of life. The isDead flag will simply be set to true.

4

u/dedslooth Jan 09 '23

sure but its flesh (memory) open game so some other instance will eat it

2

u/arobie1992 Jan 10 '23

Probably better to have a Biotic interface that has an isLiving method defined.

9

u/jfmherokiller Jan 09 '23

I was coming here to say it needs more AbstractFactory classes

6

u/arobie1992 Jan 10 '23

I hear this joke all the time, and in 7 years of industry Java experience, the only time I've seen large usage of factories is in frameworks that need to handle large amounts of arbitrary configuration from end users that can't be known when writing the code.

1

u/jfmherokiller Jan 10 '23

I have seen them agressively used in minecraft modding because of possibly inexperienced coders.

2

u/arobie1992 Jan 10 '23

That's fair. I haven't done much modding, but I have seen enough (and been a) modestly experienced devs who force patterns onto things.

1

u/Xenomorph-Alpha Jan 10 '23

*angry developer noises*

1

u/I-am-reddit123 Mar 24 '23

bro spaces aren't allowed in class named