Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by stvn (Monsignor)
on Jul 06, 2005 at 16:56 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://472876]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-19 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found