eekim.com > EEK Speaks


Sun, Nov 14, 2004

Subclassing Perl Interfaces    #

GerryGleason, who has done a ton of work for PurpleWiki recently, and I have had an ongoing discussion about when to use base classes in Perl. The reason the question comes up at all is that Perl base classes do not behave the way base classes do in "real" object-oriented languages. Because Perl does very little in the way of type-checking, defining interfaces as Perl base classes doesn't give you the same benefits as it would in other languages.    (4PS)

Nevertheless, when you have multiple classes with the same interface, I think it's good practice to define the interface in a base class, if only for the discipline of doing so. When we were designing a new pluggable back-end architecture for PurpleWiki, Gerry and I first discussed the API using the Wiki, then Gerry went off and implemented three different backends simultaneously. Today, I created a base class for those backends, and in the process of subclassing them, I discovered a bunch of inconsistencies and subtle bugs in the implementation. The point is not that Gerry is a sloppy programmer. Anyone would have made the same mistakes in the process of implementing a new architecture quickly, especially doing (and learning from) multiple implementations simultaneously. The point is that the process of creating a base class forced us to rigorously examine the interfaces of each implementation. Even though Perl doesn't do as much as it could with base classes, the processing of implementing base classes and subclassing them forces us to do our own checking, which results in better code.    (4PT)

Perl doesn't leave you totally helpless when it comes to base classes, although again, you have to do extra work to get the behavior you want. For example, you can "assure" that methods are overloaded by defining methods that croak in the base class. If these methods are not overloaded, then they will croak when they are called.    (4PU)

/tech/perl | Posted at 2:02pm

Fri, Aug 22, 2003

I Blog Like a Girl!    #

I discovered The Gender Genie from LaughingMeme, which led me to Moshe Koppel and Shlomo Argamon's algorithm, described in Nature and the New York Times Magazine. The Koppel-Argamon algorithm analyzes the text and guesses the author's gender.    (90)

The algorithm was very simple, so I implemented it as a Perl module -- Lingua::EN::Gender. I just registered for a PAUSE ID, and will upload Lingua::EN::Gender to CPAN as soon as my registration is confirmed.    (91)

See more....

/tech/perl | Posted at 3:56pm

EEK Speaks

A blog about collaboration, community-building, and the various goings-on at Blue Oxen Associates, with occasional digressions on food and other vital matters.

Archives

May 2009 (3)
April 2009 (2)
March 2009 (3)
February 2009 (4)
December 2008 (1)
October 2008 (2)
August 2008 (1)
June 2008 (2)
April 2008 (1)
March 2008 (2)
February 2008 (10)
November 2007 (14)
October 2007 (4)
September 2007 (3)
August 2007 (7)
July 2007 (2)
June 2007 (7)
May 2007 (10)
April 2007 (14)
March 2007 (17)
February 2007 (12)
January 2007 (9)
December 2006 (3)
November 2006 (11)
October 2006 (23)
September 2006 (20)
August 2006 (22)
July 2006 (5)
June 2006 (19)
May 2006 (8)
April 2006 (5)
March 2006 (12)
February 2006 (10)
January 2006 (6)
November 2005 (14)
October 2005 (14)
September 2005 (10)
August 2005 (21)
July 2005 (2)
May 2005 (10)
April 2005 (7)
March 2005 (3)
February 2005 (7)
January 2005 (8)
December 2004 (5)
November 2004 (11)
October 2004 (7)
September 2004 (1)
August 2004 (9)
July 2004 (16)
June 2004 (1)
May 2004 (3)
April 2004 (8)
March 2004 (8)
February 2004 (12)
January 2004 (8)
December 2003 (12)
November 2003 (12)
October 2003 (3)
August 2003 (15)
July 2003 (20)

Categories

Subscribe

Related Blogs

Blue Oxen Associates
The Watering Hole
Hyperscope

Blog Roll (via Bloglines)
extisp.icio.us

Miscellaneous

GeoURL

Technorati Profile