Re: OOP slow -- am I an idiot?
| From: | Tony Marston | Date: | Thu, 12 Oct 2006 08:11:28 +0000 |
| Subject: | Re: OOP slow -- am I an idiot? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-243018@lists.php.net to get a copy of this message | ||
"Roman Neuhauser" <neuhauser@sigpipe.cz> wrote in message
news:20061012023956.GB27821@dagan.sigpipe.cz...
># stuttle@gmail.com / 2006-10-11 21:28:36 +0100:
>> Richard Lynch wrote:
>> >On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:
>> >>I want to create a "customer" class which fetches its attributes from
>> >>a MySQL database.
>> >
>> >No, you don't. :-)
>> >
>> >This is a classic example of the "obvious" OOP solution being wildly
>> >inappropriate.
>>
>> Ok, so I now find myself in the unusual position of disagreeing with the
>> Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is
>> all about.
I have to disagree as well. There is absolutely nothing wrong which the
approach of creating one class for each table in the database. It cannot be
wrong for the simple reason THAT IT WORKS! It is also the simplest approach
as it keeps all the business rules for each database entity in a single
class. Also, by keeping the structure of each object in sync with the
structure of the database you don't have to introduce another pointless
level of complexity with OR mappers.
Those OO "purists" who insist on creating object hierarchies which bear no
resemblance to the database structure are making a rod for their own backs.
That notion of "purity" is my idea of "putrefaction".
--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org