DEV Community

Discussion on: The Problem with Interfaces, and how Go Fixed it

Collapse
 
oscherler profile image
Olivier “Ölbaum” Scherler

Reading this, I’m thinking it could be called “The Problem with Duck Typing, and how Go Fixed it.” I don’t know how good code that was written without the knowledge of the existence of an interface will be at implementing it. But if you write code that expects an object that you can order, mix, and eat, then instead of enduring three “has such method” tests in every method that uses such an object (like you spend your time doing in if you do duck typing in Ruby), you can define an interface that turns those tests into a type declaration, and be done with it. I my opinion, that’s a fix for the ordeal that duck typing it in practice.