Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
elazar10308yDuck typing is an awful term. It's not that we conclude that it is a duck based on the behavior. It's that *we don't care*. It's the quackability that we care about, not the species.
-
atheist99288yMy point is that one cannot infer behaviour. In python if something supports getitem with a number argument is it a dict or a list? Does it support slicing? Does everything passed to that function do those things?
Sure, if you wrote the whole project you might know the answers but that's not how software dev works in the real world. You write code and hope it doesn't crash.
That's a stupid fucking way of working. -
atheist99288yTrue, but if you adhere to the object contract then you can be at least sure of code correctness to the api boundary. Then if someone else has done something stupid that's their problem.
-
elazar10308yDuck typing is similar, but you have more fine-grained control over the relevant parts of the contract, and you rely more on conventions in naming things.
Related Rants
Duck typing
If something quacks that does not mean it's a duck. A duck has wings, can fly and is renowned for eating bread. For all you know what you have is a tape player.
undefined
duck typing