Yoz Grahame's Unresolvable Discrepancy

I came here to apologise and eat biscuits, and I'm all out of biscuits

And behold, there came the time of Refactored Overloaded Objects

Posted: March 21st, 2004 Comments Off

If
you’re a Perl coder who hasn’t been keeping a close eye on CPAN then
you may have missed the latest chunk of code making quite a stir,
namely Brian “Ingy” Ingerson’s marvellous IO::All. And it is
marvellous: if Perl is the Swiss Army Chainsaw then this is the new
light saber attachment – can’t do anything you couldn’t do previously
but it slices through most IO jobs in one or two lines, from file
slurping (one line, obviously) to creating a forking server (er, two
lines). This Perl.com piece
would be a great introduction if another burst of coding from Ingy
hadn’t rendered it half-obsolete a mere three days later. But, dammit,
that’s what we like to see!

IO::All’s design could be described, for want of a decent OO
education, as “overload one class with a billion different uses” and in
this case it seems to work well. The vast majority of the code revolves
around grabbing code from other modules and wrapping them up in several
big contextualising switches so that this single class is almost all
you need for your to-ing and fro-ing with the outside filesystem. In
other words, it’s all about the interface. It feels very Perlish in its
mixture of minimal code and DWIMness so it’s not surprising that many in the Perl community have jumped on it gleefully.
This “The Best $DOMAIN Functions In The World… Ever!” approach to module-building is infectious, and Yung-Chung Lin’s Var module is probably going to be the first of many imitators. If you fancy having a go yourself, then Ingy’s Spiffy
base class is what you want to start with, but please use your enhanced
exporting powers wisely: packing a single class with tons of functions
(a la Python) is fine and pretty, but doing that to the default
namespace (a la PHP) is just inconsiderate.


Comments are closed.

Archive

The complete list of posts lives here.

yoz's bookmarks

  • Lee Maguire – WikiLeaks and the future Hydra
    Lee on the similarities between WikiLeaks and comic-book villainous organisations.
  • WebGL Inspector
    Lovely Firebug/Web Inspector-alike for WebGL, usable either as an extension (for the top WebGL-enabled browsers) or embedded JS. Under rapid development.
  • ge.tt
    Gorgeous hack: web-based file sharing service where the link to your file works while it's still uploading. Instant, super simple and free. (via DMM)
  • Async.js (Caolan McMahon)
    One of the many flow-control packages for Javascript, of which at least 3 are called async.js. This one has some really nice tricks, especially auto() which fires off function calls as soon as their dependencies are met.
  • Adequately Good - JavaScript Module Pattern: In-Depth
    Really good explanations of several useful function and module patterns to use when building your own
  • News flash: Deadly terrorism existed before 9/11 - Ask the Pilot - Salon.com
    The quantity of air-travel-targeting terrorist attacks between 1985 and 1989 would be unthinkable today; yet the presented danger and precautions taken are far worse
  • 100 Free High Quality WordPress Themes: 2010 Edition - Smashing Magazine
    Some really nice minimal ones here, along with good theme tools and a bunch of things that I didn't know WordPress could do
  • Lenore Skenazy: 'Stranger Danger' and the Decline of Halloween - WSJ.com
    Despite American parents' increasing paranoia, Halloween may be the safest day of the year for kids. (via schneier)
  • becoming the alien: apartheid, racism and district 9 « a subtle knife
    Superb essay on District 9's relevance. "It confronts us with our complicity with racism, by making us identify with the perspective of the racist, inviting us to feel the revulsion of the xenophobe – and then pulling the carpet from under our feet." (via kevin marks)
  • Music Hack Day: The Uninterrupter - Andrew Shearer's Other Blog
    "For an increasing number of us, the same device we use to play music also handles email and GPS directions." The presented solutions are as brilliant as they are ludicrous. (via extensionfm blog)

yoz on twitter

    follow me on Twitter

    Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org

    Content licensed under the Creative Commons (Attribution - Share Alike) | Theme based on Clean Room by Columbia, MO Web Design