You are here: Re: Using a Resource as a Class Property « PHP Programming Language « IT news, forums, messages
Re: Using a Resource as a Class Property

Posted by Sanders Kaufman on 07/23/07 04:34

Jerry Stuckle wrote:
> Michael Fesser wrote:

>> Quite simple: A base class with a member variable and a method that
>> performs some action with that. Since this is done in the constructor,
>> every child class has to be able to initialize the data before calling
>> the parent constructor, as you can see in B::__construct(). If PHP would
>> automatically call the parent constructor, this would be impossible.
>
> Generally unique to PHP. Java, C++ and SmallTalk all call the base
> class constructor automatically before any code is executed in the child
> class constructor.


OK - to update my understanding...
PHP doesn't automatically call constructors BUT doing so would be more
in keeping with the Tao of OOP.

Zat right?


> Also, the parent should never have a dependency on the child class, and
> the parent's class constructor should never depend on anything in the
> child class other than what is passed to the constructor.

Wow. Cool. When I built my classes, I didn't KNOW it should be done
that way, but it FELT right.

I seriously considered writing the classes in a way to where the parent
would *presume* all kinds of stuff about the child, but it didn't jibe
with my obsession with atomicity - so I didn't do it.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация