Protocol
The similarity of this approach to protocols was clear to users of OOP languages long ago. Smalltalk and ObjectiveC, both dynamic OOP languages, have long used the term Protocol to refer to this concept.
The Protocol concept is certainly useful, if only to give a name to a particular set of messages.
It would be nice to know ahead of time what methods a Ruby object accepts. It would be nice to talk about a bunch of classes as all defining read, write and size methods as IO classes. Even if you could use some kind of marker interface (or marker module) that says, “Hey, you probably don’t care but my object might respond to these methods..”, ruby doesn’t itself protect or enforce it anyway.
Tags: Ruby