Re: PHP5 and the DOM model

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2008-04-18 at 13:17 -0600, Nathan Nobbe wrote:
> On Fri, Apr 18, 2008 at 1:02 PM, Robert Cummings <robert@xxxxxxxxxxxxx>
> wrote:
> 
> > What he means is don't ask for the data literally (by property name) ask
> > for it via a method. This allows wrapping the data in "work". This is a
> > moot issue in PHP since PHP allows trapping the property accessor.
> 
> 
> i dont think its moot.  if your trapping it via __get() or __set() its still
> the same action; driving the client through a well defined interface; if it
> just happens to have the same name as the property itself, its still the
> same concept.  you have the 'work' in the magic methods (at a minimum the
> initial part), instead of the getters and setters you would build yourself.
> and personally, i think it much cleaner to have separate methods for each of
> the properties rather than one big function which has to internally route
> control via some sort of logic, be it conditional, variable functions or
> w/e.
> besides which, for the magic methods to work, the variables have to be
> 'inaccessible' according to the docs which means protected, private, or
> non-existent; and barring the case of non-existent we are right back in the
> realm of encapsulation.
> unless you meant something different by 'trapping the property accessor';
> which you usually do pull some unexpected stuff so im waiting for your next
> clever example to prove me wrong :D

Nope, the point is moot. If I've made my properties publicly accessible,
now, due to the ability to trap via __get() or __set(), I can remove
them and handle them. Thus, I can retrospectively change the semantics
without care for having exposed the properties themselves. The point is
moot here because the option now exists to enhance properties at a later
date without the need to drive the enhancements through a method the
user must call (the details of __get() and __set() are hidden from the
user of the properties ;) 

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux