On Wed, 2004-06-30 at 10:45, Ross Werner wrote: > > > > Mixing presentation and logic is bad because it's essentially spaghetti > > code. With stateless web pages it's even worse. There's no way you can > > easily understand and follow the logic when a php program uses such > > mixing of code and html. > > Does this apply mostly/solely to creating whole-sale _applications_ in > PHP, or does it also apply to creating a web site?
MVC applies to both, in my opinion. > > To me, it seems like if you fail to use some sort of templating scheme > with your web site, it's a fault of your web site design, not PHP. You > could do exactly the same with pure HTML, or embedded perl, or anything > else for that matter. You are exactly right. Using JSP or PHP I can right crappy code that mixes logic and presentation, and is a mess of redirects, and links. There are a number of templating libraries available for PHP. I give it as my humble opinion that even for the smallest apps you should be using one of those templating apps. It just so happens that programming an unstructured non-MVC app in java is so painful that nobody does it anymore and most use a templating framework like Struts or Tapestry. Most php programmers are only dimly aware of the templating libraries (I wasn't aware of them until recently). Without these, PHP lends itself well to messy apps, and also a certain quality reputation that is undeserved. A language is a language. They are all turing-complete and formally equivalent. > > I mean, if you were creating a PHP-Gtk application or a Visual Basic > application or a Python application, don't you mix presentation and logic > in precisely the same fashion? Or are you supposed to use templates for > your locally-run GUI applications, too? Good GUI design is always some varient of MVC, although the degree of separation between the parts is not always the same nor should it be. GTK by it's very design is quite strict MVC. The GUI classes and the XML file that describes the GUI is the the template. Your event-driven code is the control. MVC has limitations and problems and often things are blurred between the parts. However, modularity and clean separation of code is always a good idea, even essential in today's large-scale RAD apps. > I guess I'm just not seeing how this is superior. I do the vast majority > of my coding in PHP, so I'd be highly interested in how to make what I do > better. I see many problems with "the system," but the problems seem to be > with the HTTP protocols, HTML itself, and various other issues rather than > being "PHP Problems". Back in the day I remember implementing a GUI in a procedural fashion (not knowing about the event-driven MVC paradigm). It worked but was painful and downright messy. The event-driven paradigm was superior for this thing. > > This is not to say that PHP doesn't do really stupid things sometimes. > Like magic quotes, for instance. But I fail to see how PHP encourages > spaghetti code more than any other language used for generated dynamic > HTML web pages. From my vantage point, the problem isn't PHP--it's the > nature of the realm it's most often used in. You are correct. JSPs and raw Servlets suffer from the same potential problems. It's about the tools. I just happen to think Tapestry is the neatest thing I've seen in quite a while. Michael > > ~ ross -- Michael L Torrie <[EMAIL PROTECTED]> ____________________ BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________ List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
