note 40773 added to keyword.extends

From: Date: Sun, 14 Mar 2004 12:09:14 +0000
Subject: note 40773 added to keyword.extends
Groups: php.notes 
Request: Send a blank email to php-notes+get-66818@lists.php.net to get a copy of this message
I recommend against using the examples here given for multiple inheritance. The essential problem is having readable code. If you want to be able to read your code in a few months, or if you want others to be able to read your code, you're better off using member variables to store class instances than using hacked on multiple inheritance. One of the big advantages to multiple inheritance in a language that properly supports it like C++ is that you can see, in the class declaration, what it inherits from. In the example where you extend some class called MultipleInheritance, that only obfuscates your class's ancestry. So, use inheritance, it's good. But it's not the be all end all of solutions. If it were, we wouldn't have templates and various other things in C++. So don't depend on it. Instead of asking yourself "How do I use inheritance to solve this problem?" you should ask yourself "Is inheritance the right tool to solve this problem?" If the language doesn't support multiple inheritance and you're trying to use it anyway, then you have certainly chosen the wrong tool to solve your problem. ---- Manual Page -- http://www.php.net/manual/en/keyword.extends.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40773 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40773&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40773&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66818) next »