Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Can I please have *simple* modules?

by demerphq (Chancellor)
on Nov 24, 2005 at 08:50 UTC ( [id://511357]=note: print w/replies, xml ) Need Help??


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

I don't use modules like C:MM or kin. I think they are a waste of time. Its far far easier to handcode such factories to your individual taste and requirement than it is to try to fit your requirements into the way modules like that expect you to do things. You asked in another threads why people dont use Traits. Well, for all I know I do use traits. Its just I dont use Class::Traits or any module like that to manufacture them.

You mention Spolsky defense of NIH, which brings to mind something that I read in Code Complete: never use wizards you didnt write. I consider method factories and class factories to be wizards I didnt write so I dont use them. Hand coding stuff like this is acceptably fast (c'mon folks, writing method factories is trivial stuff) and it then fits your requirements to a T. Using other peoples code just introduces dependencies and points of failure that are difficult to manage.

Now, dont go an take what im saying here and assume it means I dont agree with code reuse, thats not at all what I'm saying. I use CPAN stuff all the time. But I dont use any of the "helper class" stuff. So far every time I have its proved to be both an exercise in frustration and a big waste of time.

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

Replies are listed 'Best First'.
Re^2: Can I please have *simple* modules?
by siracusa (Friar) on Nov 24, 2005 at 19:19 UTC
    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.

      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.

Re^2: Can I please have *simple* modules?
by itub (Priest) on Nov 24, 2005 at 14:33 UTC
    I agree 100%. I'll never understand why people are willing to add another dependency on a third-party module to use a "helper function" that saves a few lines of code (sometimes even just one, yes, one line of code!). My policy is to only use helper modules/functions that come with the perl core (and then not all of them).
Re^2: Can I please have *simple* modules?
by sauoq (Abbot) on Nov 24, 2005 at 19:29 UTC

    I also agree entirely with this. I've no interest in incorporating code that restricts how I must code my own modules. And I don't want someone else's code to have that deep of an impact on mine. Using a module that provides a specific set of functionality through a well defined API is something else entirely.

    -sauoq
    "My two cents aren't worth a dime.";
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://511357]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found