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

Re^2: Should I use Fields, InsideOuts, or Properties?

by stvn (Monsignor)
on Jul 06, 2005 at 16:56 UTC ( #472876=note: print w/ replies, xml ) Need Help??


in reply to Re: Should I use Fields, InsideOuts, or Properties?
in thread Should I use Fields, InsideOuts, or Properties?

Encapsulation of an object means you should never access attributes directly but use accessors and mutators(getters and setters).

This is only partially true. Encapsulation means that you have private data which is not accessible from the "outside" (or more specifically, you can control the accessibility). What you are doing with AUTOLOAD is no better then just accessing the underlying hash directly.

IMO accessors and mutators should only be created when a truly valid need exists for them. Objects are meant to be a collection of (encapsulated) data and behaviors, but if all your behaviors are simply accessors/mutators, then you might as well just have a struct/record-type.

-stvn


Comment on Re^2: Should I use Fields, InsideOuts, or Properties?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-10-25 03:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (141 votes), past polls