3 ms·
Honestly, I think I just don't understand it. When I call the method doThis() on some object implementing the interface Thingamabob, I am assured that it will d
by morsch 15y ago
Honestly, I think I just don't understand it. When I call the method doThis() on some object implementing the interface Thingamabob, I am assured that it will do whatever Thingamabob::doThis() is obliged to do. Of course Thingamabob is short for a fully qualified name, there is no ambiguity here. And of course I am relying on whoever wrote the doThis() implementation obeying the contract of Thingamabob::doThis().
With duck-typing, how do I know that doThis() is actually an implementation of a (non-declared) interface? The chance for accidental clashes seems exceedingly high, the space of method names is not all that large. And what does it actually buy you?