Annoying interfaces

jdavidb on 2003-07-18T14:39:51

On this date in history, I was annoyed by both HTML::TokeParser::Simple and Lingua::EN::Fathom in that the constructors for both take only a filename. In each case, I want to just send it a scalar variable full of content and have the processing done. I could use IO::Scalar to make my content appear to be a filehandle, but I need a filename.

Back at my old job, I used to code all kinds of procedures that would accept either a filename or a block of text. It was easy to just not have to worry about it.

Of course, who can complain? Both of these APIs do wonderful things!


It's an opportunity!

pdcawley on 2003-07-18T18:19:51

Subclass it. Or patch it. Or override open...

Re:It's an opportunity!

acme on 2003-07-18T18:24:04

It's true that a lot of modules read/write from a scalar/file. It's annoying that all these modules have different interfaces and that we have to fake it sometimes with IO::Scalar.

However, I see this more as an opportunity to define an API and try and get everyone else to follow it. Well volunteered!

Re:It's an opportunity!

Matts on 2003-07-19T17:27:11

We already defined on in XML::SAX. Maybe more people should follow it :-)