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

Re^2: Why is a hash the default "object" in oo perl?

by theAcolyte (Pilgrim)
on Jul 19, 2004 at 00:10 UTC ( [id://375442]=note: print w/replies, xml ) Need Help??


in reply to Re: Why is a hash the default "object" in oo perl?
in thread Why is a hash the default "object" in oo perl?

Heh ... thanks! Really what was bothering me was a statement I've read over and over in texts that deal with Object-Oriented programming (but not about using it in any particular language) which was:
A subclass shouldn't need to know anything about its parent's implementation, and the parent shouldn't need to know anything about a child's implementation

Or something along those lines. And while I was experimenting by trying to create a very generic "person" object (which could then become person::client, person::employee, person::vendor etc) I realized that I would end up violating both of those ideas by storing data inside a hash-ref as object

If I had been working on this for a paid project I would have just plowed forward as I'd be the one writting the subclasses anyway ...

However, since this was a learning experience, I was annoyed by the idea of 'cheating' and figured there had to be a way. I had once seen (here on perlmonks) using braces around a subroutine { $var; sub { ... }} to keep a variable alive between calls to the subroutine and used that in figuring out what I did.

I think after I read/learn Abigails implementation -- which I have no doubts is much more refined then my Saturday afternoon of hacking around -- I would likely use this as my default OO style.

theAcolyte

  • Comment on Re^2: Why is a hash the default "object" in oo perl?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (1)
As of 2024-04-24 14:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found