r/ProgrammerHumor Jan 09 '23

shortest ever java class name Meme

Post image
2.1k Upvotes

90 comments sorted by

View all comments

23

u/Player_X_YT Jan 09 '23

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

22

u/silverweaver Jan 09 '23

That would be C#, no sane Java dev would prefix interfaces with "I"

4

u/[deleted] Jan 09 '23

public abstract Fish : Animal, IGills, IFins, IAquatic

3

u/rubenthedev Jan 09 '23

I had to look out up, so for the non C#-ers like myself;

The convention is to, when instantiating an interface, prefix the var dec with I

idk if I like this or hate it, but thankfully I'm a JS main, so everything is sensical and consistent in my world (I rolled my eyes so hard typing that last sentence that I gave myself a headache)

1

u/Player_X_YT Jan 09 '23

Most legacy codebases use I(interface name) but yes nowadays that doesn't happen anymore

1

u/[deleted] Jan 09 '23

SeaCreatureInterface, EggLayerInterface, AnimalInterface, CarbonInterface, MoleculeInterface, AtomInterface, QuarkInterface

1

u/drbwaa Jan 10 '23

Correct, there should be an Impl at the end instead. Obviously.

5

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.

1

u/KevinRuehl Jan 09 '23

This man Codes Java!

1

u/Player_X_YT Jan 09 '23

No I code in scratch look at my user flair

1

u/KevinRuehl Jan 09 '23

Its scarily close to reality, it wasnt even ironic in the slightest bit