note 40773 deleted from keyword.extends by danbrown

From: Date: Wed, 17 Jun 2009 19:04:25 +0000
Subject: note 40773 deleted from keyword.extends by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157026@lists.php.net to get a copy of this message
Note Submitter: Dave Fancella ---- 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.

« previous php.notes (#157026) next »