Re: [PHP-LANG] CLASSES AND OBJECTS

[email protected] ("Yasuo Ohgaki")
Newsgroups php.lang
Message-ID <[email protected]>
I'm not qualified answering if PHP is going to support multiple inheritance or
not.

Anyway, you have been asking around all PHP related mailing list, so I post my
thought about PHP coding.

If there is multiple inheritance, life could be easier to design/create/use
objects. (Well, maintenance could be a problem if design is not good) However,
if you use multiple inheritance under PHP, all class definitions must be
loaded/parsed/compiled into PHP every time. This hits performance as class
getting larger and larger, since amount of loading/parsing/compiling increases.
Many PHP application is written for Web Application which is performance is very
important. Loading/parsing/compiling codes, that are not required at the moment,
is generally not a good idea.
(For example, my authentication class has login()/logout() method, but it just a
redirect to URL. Actual login/logout is performed in that URL. Since
authentication class is loaded every time user view pages, but I don't need
login()/logout() code every time.)

Rather than using multiple inheritance, I think we are better off using "Has A"
relationship or what ever design suitable for application. (PHP does not support
it currently, anyway) It is possible to load class definition only when we need
objects, we can improve performance hopefully if we load code when it's needed.
(Form my experience, too much of doing this slows things down also.)

It may not be true for users using cache product like ZendCache in most cases.
But it still better to load smaller amount of codes if it's possible and
appropriate.

Hope this helps,
--
Yasuo Ohgaki


""alberto"" <[email protected]> wrote in message
news:[email protected]...
> Anyone know if one day PHP will support multiple inheritance?
> I think it's very important...
>
> For example, will PHP support this code:
>
> class A extends B,  extends C   {
> ....
> }
>
> where B and C are classes?
>
> Thanks!
> Alberto
>
>
>
>
>
> --
> PHP Language Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> To contact the list administrators, e-mail: [email protected]
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.