News for hackers. Stuff that matters.
Re:OOP practiced backwards is "POO" by swannodette on Friday December 10, 2010 @08:36PM (#1993876)
Because it allows programmers to define a minimum contract for behavior. Instead of having to subclass (and being implicated into a hierarchy) you can instead provide any object as long as it satisfies that interface.
Re:OOP practiced backwards is "POO" by russellperry on Friday December 10, 2010 @10:00PM (#1994017)
Allowing a class-level contract would fundamentally alter the dynamic nature of a language like Ruby. It might be cool (although I personally don't see the benefit), but it wouldn't be Ruby.

What mechanism would enforce the contract anyway? The best you could hope for would be a runtime error thrown when the interpreter detected the incompatibility, and you can do that manually now (I do it frequently to imitate abstract classes).

Re:OOP practiced backwards is "POO" by rapind on Saturday December 11, 2010 @03:56AM (#1994503)

  class IAnimal
    def growl
      raise
    end
  end
Re:OOP practiced backwards is "POO" by russellperry on Saturday December 11, 2010 @11:45AM (#1995123)
Yeah exactly! 'raise "not implemented"' is how I imitate abstract classes (on the rare occasion that I need them).