Hello friends,

I know most of you have probably heard of Moose already. Many of you have probably even used it. I am certainly not one to claim I'm the first on any given block. But, after finally bucking up and building something with it, I felt a burning itch (maybe I should get that checked out?) to share my enthusiasm.

I wrote an interface to access data from a website. I do this a lot, but the busywork involved in making even a very simple OO API usually prevents me from bothering. Mostly, I write a couple of subroutines to abstract the various WWW::Mechanize and HTML::TreeBuilder bits, build some plain data structures, and hack things up and down the stack.

On a lark, I thought I might want to do it a little differently this time. I installed Moose, went through the docs a bit, and discovered the development model was surprisingly fun. Even while learning how to prod things into the proper shape.

The beginning was crude and simple. I defined the attributes of each object with has calls, and the object interrelationships with isa declarations. The basic data model took very little time to get right. I quickly had a program that pretended it was reading my LibraryThing library.

Then I wrote default hooks that fetched the appropriate data from the site. It kind of snuck on me, but then I realized that's all I had to do. Once I had the loading code in place, it was done. I had a functional API before I even knew it. It was clear and straightforward. Even better, since the data-fetching methods were all defined with lazy turned on, the fetching doesn't happen until the data's needed.

There is a lot of functionality that comes from Moose's simple, declarative interface. All I could think of was the infamous tagline from a Ruby on Rails promotional video: look at all the things I'm not doing! I gotta say, Moose; I like it, I really do.

Three cheers for stvn!


In reply to Moose is lovely by revdiablo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.