Re: OOP slow -- am I an idiot?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--- Larry Garfield <larry@xxxxxxxxxxxxxxxx> wrote:
> For your rudimentary example of object-relational mapping below, yes, 
> performance is going to be atrocious.  That's because you're not taking any 
> advantage of the features that using OOP gives you.

Well, I /thought/ I was taking advantage of black box-style hiding (not sure what it's called),
that is, making sure the only place I type (and modify) my SQL query is hidden inside the private
method of a class.


> Again, pull extra data if you can.  A somewhat larger result set is (usually) 
> better than multiple queries.  How much you want to front-load in your object 
> and how much you want to defer to later depends on your specific problem and 
> how frequently the data will be used.

OK that somewhat answers the question.


> 5) If you need to grab 100 objects at once, but just need basic data out of 
> them, use a factory.  Vis, 

(code snipped)

I /think/ I understand the code.  But I'd need more than just basic data, so I probably will just
write a query.


> 6) If you need to do a complex query with a couple of joins and such, then 
> don't waste your time or the computer's trying to shoe-horn it into SQL.  SQL 
> is not inherently OO to start with!  Just write your query and loop it and be 
> happy.  OOP is not the answer to all problems.  Sometimes it does just make 
> matters worse, no matter what Sun tries to tell you. :-)

LOL

Yeah, I was thinking of shoe-horning things into SQL for speed.


> >  I want my data to _only_ be accessed from the black box called an OOP
> >  class. 
> 
> That will work and is achievable in about 30% of all situations.  For the 
> other 70%, you will have to just hunker down and *gasp* write SQL specific to 
> the task at hand at least some of the time.  How much of the time once again 
> depends on your situation and the problem you're trying to solve.

*gasp*

:-)


>From what it seems like people are telling me, it's a good idea to boot OOP for large numbers of
objects where I need more than just a little information and just use an SQL query, as I
suspected.  At least, for PHP; I wonder what Java people do in this situation.

CD

Think you&#39;re a good person?  Yeah, right!  ;-)
Prove it and get ten thousand dollars:
TenThousandDollarOffer.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux