[nycphp-talk] __get __set methods..
Adam Maccabee Trachtenberg
adam at trachtenberg.com
Wed Apr 20 19:42:14 EDT 2005
On Wed, 20 Apr 2005, David Mintz wrote:
> On Wed, 20 Apr 2005, Alex C wrote:
>
> > I really think these methods might be really handy for predefined
> > properties. Am I wrong to think that? just want to understand why this
> > might be bad idea to have these functions work with predefined
> > properties. with this runner class, i want to exclusively have
> > predefine properties for this object.
>
> I might be missing something, but if you want people to be able to get and
> set your props directly, why not just make them public and be done with
> it?
Because it breaks encapsulation. Using accessors allows you to modify
how you store/validate/etc. properties in your class without changing
the public interface to the data.
-adam
--
adam at trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!
More information about the talk
mailing list