YAPC day 3: Abigail's two methods of OO

jdavidb on 2002-06-28T17:28:37

Abigail's talk started off with a basic introduction to objects in the abstract.

Objects need:

  • set of attributes
  • set of methods
  • set of inherited classes
  • means of method dispatch

If methods are closures, the methods contain the attributes for us: instant encapsulation. The attributes would also be lexical instead of hash keys. Typos would be caught by strict.

There was a really neat code example of using OO::Closures.

This is the second talk I've seen where we've seen how to build an OO programming system in Perl. There's actually lots of ways to do this. Perl is the first OO language I ever learned. Really. I have a lot of preconceptions about how things should work that give me problems in other languages, and some of these preconceptions probably give me problems in Perl, as well.

There were no uses of bless here, I believe. You know, some day I'd like to see people come up with a solution for bless besides OO; we've already seen many interesting ways of doing OO without it.

Problems with using hashes:

  • no strictness
  • no encapsulation
  • lots of punctuation

An inheriting class can blow out a parent class's attribute. And of course, those attributes are internal so they are not documented.

Inheritance in Perl is HARD. In order to subclass, you actually ought to look at the code for the superclass and see how it is implemented. That's not what you're supposed to do in OO.

Inside out objects: the person next to me just tilted his head 90 degrees counter clockwise to look at Abigail's slide. I don't think he noticed it. I wonder if it helped.

You can get compile time error messages for nonexistent attributes with this system.

Class::MethodMaker, according to Schwern, isn't possible with strictness. However, source filters answer the problem, according to Abigail. There's a Class::MethodMaker::InsideOut on the way.