RE: Doctrine madness!

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

 




> -----Original Message-----
> From: Nathan Nobbe [mailto:quickshiftin@xxxxxxxxx]
> Sent: Thursday, June 16, 2011 5:39 PM
> To: Daevid Vincent
> Cc: php-general@xxxxxxxxxxxxx
> Subject: RE:  Doctrine madness!
> 
> On Jun 16, 2011 5:31 PM, "Daevid Vincent" <daevid@xxxxxxxxxx> wrote:
> >
> >
> >
> > > -----Original Message-----
> > > From: Eric Butera [mailto:eric.butera@xxxxxxxxx]
> > > Sent: Thursday, June 16, 2011 2:58 PM
> > > To: Daevid Vincent
> > > Cc: php-general@xxxxxxxxxxxxx
> > > Subject: Re:  Doctrine madness!
> > >
> > > On Thu, Jun 16, 2011 at 5:37 PM, Daevid Vincent <daevid@xxxxxxxxxx>
> wrote:
> > > >> -----Original Message-----
> > > >> From: Nathan Nobbe [mailto:quickshiftin@xxxxxxxxx]
> > > >> Sent: Thursday, June 16, 2011 9:51 AM
> > > >> To: php-general@xxxxxxxxxxxxx
> > > >> Subject:  Doctrine madness!
> > > >>
> > > >> Hi gang,
> > > >>
> > > >> If anyone out there has some experience w/ Doctrine now would be a
> great
> > > >> time to share it!
> > > >
> > > > Yeah, I've used Doctrine as part of Symfony. Both suck balls and are a
> > > perfect example of why you should NEVER use frameworks. Lesson learned
> the
> > > hard way. Re-write with your own MySQL wrappers and for the love of God
> and
> > > all that is holy do NOT make it an ORM wrapper.
> > > >
> > > > KTHXBYE.
> > > >
> > >
> > > I do believe that was the most eloquent and enlightened email that has
> > > ever graced my inbox.  Thank you for taking the time to edify us with
> > > that pithy reply.
> >
> > Glad I could be of service. There was no point in elaborating more on
> either Doctrine or Symfony any further.
> 
> You've been even less helpful than the broken community surrounding
> doctrine.  Thanks for your effort daevid, I know you tried hard ;)
> 
> -nathan

You asked if anyone had experience with Doctrine and to share the experience. I did just that *wink*. I never claimed to have a solution to your Doctrine problem, other than the fact that Doctrine is in itself the problem. You are in a recursive loop. :) Think of me as the "return;". You're welcome. 

In all my 25+ years of coding experience with any language and especially PHP, I've learned the hard way that the one-size-fits-all approach of a generic framework and the bloat of an ORM just doesn't work. It looks wonderful, trust me, I've fallen prey to its sultry gaze myself. Hell, I've even written tools that started to look like ORMs and Frameworks, and then there comes a point when you realize their cost is too high. You're better off (IMHO) making some very efficient wrapper functions for sql_query(), sql_save() [does insert/update intelligently], sql_delete(), etc. and not get all fancy with making a SQL class/object and all that crap either.

OOP is great for many things, but it's not the answer to everything and developers need to know when to use the right tool for the job. It has also been my experience that a SQL wrapper is best as a procedural system since it's called so frequently and often. Doing some silly:

$con = new DBConnection();
$con->query('select * from foo');
$myresults = $con->getResults();
$con->close();

Or whatever is a waste.

$myresults = sql_query('select * from foo');

Is far more efficient and easier to read.
Let the function open a connection, and do all the work.

The ORM dealios complicate things, as now you have some stupid YAML file to maintain, and you have to make objects that relate to other objects (1:M, M:M, etc.) and after a while, you start to think, "shit, I could have done this with like 3 SQL statements". The ORM's fatal flaw is it's one-size-fits-all Achilles heel. 

Example: We used to have this crontab job that would update news stories from RSS feeds we harvested around the web. It was taking HOURS to complete. Mostly because for each story, we had to create a new Doctrine object thingy and all the related table objects and then update the instance object, then ->save() or whatever. Do that over a hundred-thousand objects and stuff starts to slow down. We converted it to use straight SQL calls and it ran in under 10 minutes. YES. From HOURS to minutes. An order of magnitude faster.

Just trying to save you (and anyone else) the time and trouble. I don’t dislike ORM and frameworks because I have some axe to grind, like I used to write a framework and it cheated on me and so I'm all jaded... No. I dislike them from experience over years of practical real-world implementations. I have tried them. I *WANT* to like them, I really do. I was very excited when Zend Framework came out... and then... I used it, and realized it was like the others. Bloat. Slow. Confusing. Cumbersome.

The last thing I'll leave you with is that, when you start to rely upon one of these ORM/PHP frameworks, you're not only stuck with it -- warts and all -- but you have to TRAIN other people to use it as well! If you find a bug, you either have to maintain it forever in your own branch, or hope the developers of the framework fix it. When you hire new people, you always have to add some caveat to the job request, "Zend Framework, Doctrine, Symfony, CakePHP, experience a plus". It's hard enough to find _good_ PHP developers, let alone ones that are in niche like that.

(BTW, my company is privately held, 14yrs old, makes $200MM/yr profit, is like the .com startup days as far as perks, fully benefits & matching 401k, has profit sharing every quarter and is hiring if anyone is interested. :) 

d.


-- 
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