Re: Advantages of declared vs undeclared object properties

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

 



On Sun, May 25, 2008 at 3:51 AM, Weston C <westonc@xxxxxxxxx> wrote:

> In a setup like you've got with a SimpleXML object, where object
> properties aren't necessarily declared in the class definition but are
> added on an ad hoc basis, is there any performance hit?
>
> If not, other than the ability to mark properties as private, is there
> any other particular advantage to declaring them at the top of the
> class definition?


its often quite helpful so that other developers, and even yourself know
what exactly is going on inside a class.  dynamically added variables are
only visible at runtime, and therefore are difficult to understand during
design time.  SimpleXMLElement is exceptional, in that it has rather
specialized semantics in terms of its interface.  without such well defined
semantics, imagine just adding and retrieving variables to an object,
ad-hoc, all over the place; it could easily lead to a big mess.

-nathan

[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