You are here: Re: References between nested objects (PHP4) « PHP Programming Language « IT news, forums, messages
Re: References between nested objects (PHP4)

Posted by Hilarion on 09/06/05 18:43

> Yes I am sorry the example code was a poor example; I was quite tired and
> annoyed when I wrote it. The classes actually behave the way you say they
> should:
>
> - common_functions
> - entity extends common_functions
> - "thing" extends entity
>
> "Thing" will be the class to be actually instanciated, while some "things"
> can have subclasses (as page extends rubric, because a page needs all the
> properties and methods that a rubric has),

Consider using common base class (eg. "document_fragment") for "rubric"
and "page" instead of inheritance between those.


> and the relations between the
> objects are handled at entity level via parent and order properties - thus
> theoretically every kind of "thing" could be assigned to every other.

You should be more type-safe. I mean if the reference is always to an object
of specific class and is mostly used as the class, then you should make
sure, that it's always referred to as this class, not some base class.
Eg. you should use type hinting in PHP 5 and "instanceof" operator (in PHP 5)
or "is_a" function (in PHP 4 or 5).


Hilarion

 

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

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