User avatar
Two Hollywood Phonies @autumn@cafe.autumn.town
4mo
what is the point of a Java Interface
1
0
0
0

User avatar
Two Hollywood Phonies @autumn@cafe.autumn.town
4mo
i think this is the first thing my python-brain is struggling to understand, it's something that is intended to ensure that if you're going to write several different "types" of class, ensures that they all implement the same stuff?
1
0
0
0
User avatar
Two Hollywood Phonies @autumn@cafe.autumn.town
4mo
e.g payment processor, you have a PaymentProcessor interface and then whenever you want to accept payments from Credit Cards, Crypto, whatever you use the PaymentProcessor interface to ensure that a future step has all the correct information?
1
0
1
0
User avatar
kopper colon_three @kopper@not-brain.d.on-t.work
4mo
@autumn instead of your code having to reason about all PaymentProcessors ever, your code only programs against a PaymentProcessor interface (exposing a, say, transfer(acc1, acc2, amount) method), and then at runtime you can swap any PaymentProcessor you want in and it'll work the same.

in python you'd Just assume the type has the methods and fail on runtime if not, in java the compiler makes sure of that
1
0
1
0
User avatar
kopper colon_three @kopper@not-brain.d.on-t.work
4mo
@autumn in "typed" python with mypy and pyright and such there is a Protocol concept that's pretty much the same thing
1
0
3
0
User avatar
Two Hollywood Phonies @autumn@cafe.autumn.town
4mo
@kopper ohhhh right yeah you'd be able to swap them out if they implement the same interface, okay! that's actually pretty neat then
0
0
1
0