http://www.perlmonks.org?node_id=511503


in reply to Re: Can I please have *simple* modules?
in thread Can I please have *simple* modules?

It all depends on the complexity of the methods you're making. Let's say I have 4 or 5 "inherited sets" in a particular class. I'm saving a bit more than just a handful of lines of code by using a method maker in that situation. But the best part is that if there's a bug in my inherited set implememntation, I can fix it in one place (the "no code duplication" thing strikes again) and all my classes that use inherited sets benefit from the fix.
  • Comment on Re^2: Can I please have *simple* modules?

Replies are listed 'Best First'.
Re^3: Can I please have *simple* modules?
by demerphq (Chancellor) on Nov 24, 2005 at 19:34 UTC

    Looks to me like you wrote that code. Which means it doesn't violate the "don't use wizards you didn't write" rule. And yes, I too have written such code. For some of my work code I have a shared framework where I have method manufacturers. But I wrote them, they fit _exactly_ to my needs. I'd never upload them to CPAN because quite simply no other set of applications would ever want to use them.

    In other modules I also have method manufacturing code. But again I wrote it. It does exactly what I need, and if I need to I will totally rewrite it for the next release. In my case I also fix one place and it fixes all my code using it, but all the code using it is all the code that will ever use it. And frankly I think that makes a lot more sense than reusing some of the stuff on CPAN. I have full control, understanding and insight of the methods, and they match my requirements and my thinking patterns exactly.

    I guess this is like shoes or other custom clothing. Sure you can by mass-produced shoes and like them, but if you go to shoemaker and get a custom pair youll never complain about the fit, and you certainly wont be lending them to anybody else. To me method factories are like shoes. They should always be custom because they fit better that way, and they should never be loaned to somebody else, because they are designed for my feet not theirs.

    ---
    $world=~s/war/peace/g

      I too have written such code. For some of my work code I have a shared framework where I have method manufacturers. But I wrote them, they fit _exactly_ to my needs. I'd never upload them to CPAN because quite simply no other set of applications would ever want to use them.

      I wrote those methods for a specific project, but I'm glad I uploaded them to CPAN because I've used one or more of them on every other significant project I've done since. Yeah, I'm still technically using code that I wrote, but my point is that the code turned out to useful in contexts other than the specific one I wrote it for.

        Its not surprising to me that you have found your code suitable to your programming style and thought processes. The real question is, how many other authors find your method factories suitable to their programming style and thought processes. And if every one of us with a custom method factory that we prefer uploaded it to CPAN there would be hundreds of such modules, all slightly different, and all the more useless as the difficulty of figuring out which is The One To Use would become all the more intractable.

        Anyway, I should add that releasing such a factory as part of the Rose framework is to my mind totally fine. You arent advertsing it as a generic method factory, and you aren't suggesting that people outside of yourself should use it for anything not Rose. Which seems to me on an abstract level to be about the same as DDS where i have about 10 lines of code that do method generation. I didn't bother to stuff it into a seperate module because DDS isn't a framework. But to me the two are both just utility code used to make our own lives easier. They arent intended to make anybody elses life easier, which is good, because they probably wouldnt.

        ---
        $world=~s/war/peace/g