Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Procedural vs OOP modules

by perlfan (Vicar)
on Oct 29, 2021 at 08:57 UTC ( #11138183=note: print w/replies, xml ) Need Help??

in reply to Procedural vs OOP modules

I've come to the conclusion that what most people want when they think of OOP is Perl are is this "oop" interface that uses uses the $myobj = FOO->new; idiom + accessors to fields. E.g., the more I use Util::H2O, the more this is also clear to me - at least in what I want.

My recommendation is to go with the "oop" interface but only for the instantiation of the "object" and for providing accessors for the fields. I'll also add, that when I see use a module that doesn't provide this, it feels a little yucky. Beyond that, Perl "OOP" fur real is the domain of an extremely vocal but tiny minority. It is very true that going beyond the means for instantiating the "object" and providing accessors necessarily yields code that looks - and behaves - like a completely different language. Again, going back to my experience with Util::H2O I've been able to summarize my desire for "improving" OOP support in Perl to go no further than a better bless that provides the kinds of things h2o provides, but can still be used in the same way - h2o comes close to achieving this but to get the last bits of what I want requires non-idiomatic tricks.

Namely, a) using h2o to define a "class" and b) taking an already blessed reference and adding accessors to it as easily as it does for non-blessed hash references. What I really want is to be able to have a bless that can magically add accessors like h2o, but that can also be used to do surgery on already blessed references - and also remain the basis for which "OOP" modules get OOP'd.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2022-01-24 19:43 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (65 votes). Check out past polls.