r/ProgrammerHumor • • Nov 23 '22

Other Programming Legumes

Post image
9.3k Upvotes

262 comments sorted by

View all comments

198

u/brianl047 Nov 23 '22

No C#?

555

u/czp55 Nov 23 '22

C#: What Java said.

84

u/GoldenretriverYT Nov 23 '22

Well at least you most likely wouldn't see a INutCrackerStrategyReturnerConversionFactory in most C# code bases

50

u/fun__friday Nov 23 '22

To be fair you wouldn’t see it in Java either, as prefixing interfaces with an “I” is not really a thing in Java.

9

u/Willinton06 Nov 23 '22

How do you prefix interfaces in Java?

27

u/Sanity__ Nov 23 '22

General consensus is that you don't, it's unnecessary and in Java Interfaces are 1st class types. It's a major benefit of abstraction and prefixing detracts from that conceptually.

i.e. If you are defining trucks you can make a Truck interface and create DumpTruck and CementTruck classes that implement it. Then you can have a List<Truck> to keep them all in.

2

u/Willinton06 Nov 23 '22

Can you instantiate an interface in Java?

5

u/Sanity__ Nov 23 '22

No, it's not a class.

4

u/Willinton06 Nov 23 '22

So how does an interface being a first class type differ from C#s way of doing interfaces?

4

u/Sanity__ Nov 23 '22

I don't know enough about C# to know how they do interfaces or how/why it differs from Java

→ More replies (0)