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

Re: Trying to understand Perl Objects

by lostjimmy (Chaplain)
on Apr 04, 2009 at 17:48 UTC ( [id://755466]=note: print w/replies, xml ) Need Help??


in reply to Trying to understand Perl Objects

...much of the benefits with using objects will disepear.

You're really not losing the benefits of OO just because you have to store the private data in a complex data structure. Some of the benefits of OO are data encapsulation and data hiding, inheritance and polymorphism, and simply being able to provide an interface to your data.

To elaborate on what jasonk already said, you may be putting your data all in a hash, but typically your object will have accessors and mutators (getters and setters) which will hide that hash from the user of the object. So instead of the user doing something like $object->{private_array}[5], your class would probably provide an easier and more abstracted way of getting that item, such as $object->get_item(5). This also gives you the freedom to change the underlying data structure in the future without the interface changing.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-19 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found