Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Can I please have *simple* modules?

by perrin (Chancellor)
on Nov 23, 2005 at 15:57 UTC ( #511142=note: print w/replies, xml ) Need Help??

in reply to Can I please have *simple* modules?

Beware the devilish lure of writing a ::Simple or ::Lite module. I often hear people say they are writing something "like Template Toolkit, but faster and more lightweight." They eventvually discover that there was a good reason for those features that seemed pointless to them at first, and soon the lightweight module grows into a beast.

That's not really the issue here though. In this case, the issue is that the module which does what you want (Class::Accessor) requires you to inherit from it, and you don't want to.

I have a lot of sympathy for not wanting your namespace polluted. I hate it when people put things in UNIVERSAL:: and I try to be very careful about namespace stuff. However, if I avoided every module I didn't like the interface of, I would be rewriting a ton of code.

Just to name a few, Regexp::Common, CGI, Getopt::Long, Apache::Session and Data::FormValidator all have pretty annoying APIs. (I don't like the much-replicated HTML::Template interface either. Sorry Sam.)

I hold my nose and use these modules because they work, get my job done, and save me tons of time. In your case, writing something to make accessors is so trivial that I suppose you aren't saving that much time, so it could go either way. I don't personally see the interface problems as very serious though.

Regarding your troubles with Bricolage installation, I still think the smartest way to distribute an application that relies on CPAN modules is to bundle them with it, along with a build script that installs them into a local directory. This has worked really well for Krang, and the company I work for has adopted this approach for all of our software. It avoids module versioning issues and allows you to patch a broken module locally if you have to.

There is no need to run the test scripts for every single module when you build them -- just run the tests for Bricolage. If they are not good enough to tell whether you have a working Bricolage system by themselves, improve them.

  • Comment on Re: Can I please have *simple* modules?

Replies are listed 'Best First'.
Re^2: Can I please have *simple* modules?
by brian_d_foy (Abbot) on Nov 23, 2005 at 17:55 UTC

    One of our clients distributes a minicpan with his application. The user starts with a "run_me" file on the distro CD. That script configures in memory (so it doesn't change or overwrite local settings), then installs everything from its own repository. Using CPAN::Mini::Inject and some other magic, we can add or replace any file.

    It's certainly a pain when the external module authors don't acccept patches or can't be reached, but for most people they don't need to upgrade. That we might have to modify somebody else's code to deal with updates isn't all that worrisome: imagine writing all that code from scratch! We're in a pretty good place when that's our major annoyance. We've been living a pretty good life. :)

    brian d foy <>
    Subscribe to The Perl Review
      I just noticed that Module::Install seems able to do all this too: find dependencies, package them up, and install them with your project.
Re^2: Can I please have *simple* modules?
by Ovid (Cardinal) on Nov 23, 2005 at 17:04 UTC

    FYI: Class::Accessor also assumes I'm using blessed hashes. I just discovered that. So we have yet another module which doesn't do what I need (I wonder how many folks want accessor generation only to find out they must use a blessed hash with canned modules?)


    New address of my CGI Course.

      Class::Accessor does let you override get/set. You may well ask what the point of it would be if you have to override that part, but it can be done.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://511142]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2018-02-20 20:04 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.