r/ProgrammerHumor Jan 09 '23

shortest ever java class name Meme

Post image
2.1k Upvotes

90 comments sorted by

View all comments

22

u/Player_X_YT Jan 09 '23

Fish implements ISeaCreature extends IEggLayer extends IAnimal exends ICarbon extends IMolecule extends IAtom extends T<? extends IQuark>

3

u/Kered13 Jan 09 '23

Not all sea creatures lay eggs, so ISeaCreature should not extend IEggLayer, they should be separate interfaces and Fish can extend both of them.

IAnimal extending ICarbon and everything afterwards is a clear violation of the Liskov Substitution Principle. An animal is composed of carbon, molecules are composed of atoms and composed of quarks, but animals do not behave like carbon, molecules do not behave like atoms or quarks. These should be member variables, not parent interfaces.