Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Object Oriented Perl - very basic guide

by Preceptor (Deacon)
on Jun 30, 2014 at 13:46 UTC ( [id://1091720]=note: print w/replies, xml ) Need Help??


in reply to Re: Object Oriented Perl - very basic guide
in thread Object Oriented Perl - very basic guide

I'm afraid I wouldn't call that a feature - more like a bug. The whole reason to use OO in the first place is to allow encapsulation - such that you publish methods and handle what those methods actually do internally.

That's what allows me to write a module, you to use it, and then me to bug fix, tweak, extend without breaking your code.

It's something that does no harm at first, but promotes bad programming practice and burns you later - something perl is notorious for.

I've seen a suggestion that basically involves trying to enforce this, via building your object around an anonymous hashref. Because messing with attributes directly breaks first time someone does it, they don't do it a second time.

I feel largely the same about pulling in vague stuff via @_ or building an object off a hashref. It's not that it doesn't work (and in many ways, this is the biggest fault of perl - that things that _shouldn't_ work, usually do). But that you can build in some really horrific bugs and gotchas by doing it.

  • Comment on Re^2: Object Oriented Perl - very basic guide

Replies are listed 'Best First'.
Re^3: Object Oriented Perl - very basic guide
by bcarroll (Pilgrim) on Jul 06, 2014 at 20:15 UTC
    I absolutely agree with everyone else here. I wouldn't recommend leveraging the features/bugs that allow you to do something that technically isn't the correct Object Oriented approach for a large project, or something that you are planning to release into the wild (CPAN).

    And yes, just because you can do it that way (as with a lot of things in perl), doesn't mean you should do it that way.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2026-03-11 03:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.