Java/C# "interface" in Ruby?

Hello all,

This is a newbie question.
Is there anything in Ruby that is equivalent to the Java/C# "interface".

Peter J. Fitzgibbons
Applications Manager
Lakewood Homes - "The American Dream Builder"(r)
Peter.Fitzgibbons@Lakewoodhomes.net
(847) 884-8800

Depends. The standard answer is "thank ghu, no." There are some
third-party implementations on the RAA, but you don't need them.

Mixins work better than "interfaces" ever will.

-austin

···

On 8/11/05, Peter Fitzgibbons <Peter.Fitzgibbons@lakewoodhomes.net> wrote:

This is a newbie question.
Is there anything in Ruby that is equivalent to the Java/C# "interface".

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Peter Fitzgibbons wrote:

Is there anything in Ruby that is equivalent to the Java/C# "interface".

There is also http://ruby-contract.rubyforge.org/ which tries to do this in a more Rubyish way. Perhaps it will be of interest to you.

Austin Ziegler wrote:

This is a newbie question.
Is there anything in Ruby that is equivalent to the Java/C#
"interface".

Depends. The standard answer is "thank ghu, no." There are some
third-party implementations on the RAA, but you don't need them.

Agree.

Mixins work better than "interfaces" ever will.

I beg to differ here: mixin modules provide implementaitions while
interfaces just define method signatures. IMHO mixin modules are better
compared to multiple inheritance or reuse.

Kind regards

    robert

···

On 8/11/05, Peter Fitzgibbons <Peter.Fitzgibbons@lakewoodhomes.net> > wrote:

Yeah, I have to agree here. To me, the Ruby equivalent of interfaces would be Duck Typing.

James Edward Gray II

···

On Aug 11, 2005, at 9:41 AM, Robert Klemme wrote:

Mixins work better than "interfaces" ever will.

I beg to differ here: mixin modules provide implementaitions while
interfaces just define method signatures. IMHO mixin modules are better
compared to multiple inheritance or reuse.

James Edward Gray II wrote:

Mixins work better than "interfaces" ever will.

I beg to differ here: mixin modules provide implementaitions while
interfaces just define method signatures. IMHO mixin modules are better
compared to multiple inheritance or reuse.

Yeah, I have to agree here. To me, the Ruby equivalent of interfaces would be Duck Typing.

James Edward Gray II

I released "interface" on the RAA, mainly as proof that interfaces *could* be done in Ruby if you really wanted them. Note that I've never used it in actual production code.

The *only* Ruby library I've seen so far that *might* benefit from an interface is DBI, where you want to ensure that all of the DBD's have a common set of methods.

Even then, it's easy enough to simply document what methods should be defined and what they should do, then add a generic test suite which DBD writers can use to ensure correctness.

Regards,

Dan

···

On Aug 11, 2005, at 9:41 AM, Robert Klemme wrote: