On Thu, Jul 12, 2012 at 02:44:12PM -0700, Daevid Vincent wrote:

> > -----Original Message-----
> > From: Simon Dániel [mailto:simondan...@gmail.com]
> > Sent: Thursday, July 12, 2012 1:21 PM
> > Subject: [PHP] Entry point of an MVC framework
> > 
> > I have started to develop a simple MVC framework.
> Yeah! Just what PHP needs, another MVC framework....
> NOT.

And here's why Daevid is right. I've been having to work with Symfony, a
well-known framework. Nothing against Symfony, per se. It's much like
other frameworks. However, here's the kicker-- if you make an unknowing
mistake with Symfony (feed it the wrong data at the wrong time), you get
the most beautiful 23-file deep stack trace. Trying to track down why
this parameter (which I didn't even give Symfony) is making it barf is
pure torture. I'm having to wade through deep Symfony code to figure it
out. Object after object instantiating other objects, magic methods,
virtual classes, design pattern classes, etc. I didn't write any of this
code, but I've got to wade through 23 files of it to figure out what the
heck went wrong. And, oh by the way, if you don't call ./symfony cc
(which clears its internal cache) at the right time, you're screwed and
you'll never know why.

Don't get me wrong. MVC is a great idea. It's a good way to divvy up
your code. But frameworks which enforce the paradigm have a way of
getting carried away with themselves. I think a lot of the people who
write them try too hard to impress other programmers with the cleverness
of their designs. By the time they're done, there are hundreds or
thousands of files involved. Every page load has to call in a
significant portion of those files, full of deep, obscure classes. Sure
*looks* kewl. But it's about 15 levels deeper than it has to be.
Remember, this is the web, folks. Your "application" has a lifetime of
one page load, unlike the platform-native accounting program, which
you're liable to keep open on your desktop all day.

I prefer to develop shallow classes which deal with specific aspects of
page handling (dates, databases, encryption, users, etc.). Then use
those as part of the "toolkit", assembled (again on a shallow basis) in
a loosely MVC pattern.

If I make a mistake, I should be able to isolate where it is within an
hour (ideally much less). And be able to go to the specific class and
method involved.


Paul M. Foster

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

Reply via email to