Am 14.07.12 10:09, schrieb Tony Marston: > wrote in message > news:1535031289.371987.1342162338279.JavaMail.open-xchange@xxxxxxxxxxxxxx... >> >> >> >> >> tamouse mailing lists <tamouse.lists@xxxxxxxxx> hat am 13. Juli 2012 >> um 07:06 >> geschrieben: >> >>> It's Friday, so... >>> >>> Yes, it's true, I have just started looking at using PDO instead of >>> mysqli -- a bit behind the times... >>> >>> My question at this stage, is do people tend to extend the PDO class >>> for their own use, or encapsulate it in a class (or do most people use >>> it mostly in procedural code?) >> >> I stick to use it as components as it is said "Do not use inheritance >> for code >> re-use" :) >> > > The idea that you shouldn't use inheritance for code reuse is absolute > nonsense as it makes a mockery of one of the fundamental principles of > object oriented programming. If you make a mess of inheritance it's > because your implementation is flawed, not that the concept is flawed. > Next you'll be saying "don't use encapsulation"or "don't use > polymorphism". What a bunch of idiots! No, I disagree with you. Don't use inheritance for code re-use, use it for class extension! If you have a class and want to add something extra to it but what does stays in the same topic, then extend from it. If you simply extend PDO to use the PDO methods and add your own stuff, then inheritance is a bad idea. If you think of what you are doing here: You USE Pdo. So it is a component. This way you get the following benefits: - You can extend your class in your system from another class AND use PDO - You can easily exchange PDO with another abstraction layer if you like, without changing the interface, just changing the implmentation -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: marco@xxxxxxxxxx Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz
Attachment:
signature.asc
Description: OpenPGP digital signature