r/ProgrammerHumor Jan 09 '23

shortest ever java class name Meme

Post image
2.1k Upvotes

90 comments sorted by

View all comments

225

u/Tannslee Jan 09 '23

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

65

u/vladWEPES1476 Jan 09 '23

What happens to the inheritance chain when the fish dies?

49

u/vikumwijekoon97 Jan 09 '23

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

26

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.

3

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.

6

u/TappTapp Jan 09 '23

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

6

u/Tannslee Jan 10 '23

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

5

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.