Mike Macgirvin
Diary and Other Rantings
Beyond Silicon Valley
   
Saturday, May 17 2008, 04:01 pm
Mar 04, 2006
MVC frameworks

There's a lot of debate going on these days about the so-called MVC programming paradigm.  I've mentioned it before. Have a look at this page, for example. MVC stands for Model, View, Controller.

Basically, this all came about because of the LAMP programming environment. That's Linux, Apache, MySQL, and PHP. When you are writing web applications with PHP and MySQL, you've got essentially three computer languages intertwined.  HTML, PHP, and SQL. Up until a couple of years ago, you just stuck these all into a file and wrote your application. The software purists who like to write pure, clean, re-useable code found this to be an abhorent practice. Three languages in one file. Then along came RSS and added a fourth. By now most of them were frothing at the mouth. Then everybody started playing with Ajax, which relies heavily on Javascript. The software purists were now having irregular heartbeats and threatening to go postal. In fact, a lot of this debate started in 1995 when Netscape added Javascript into HTML pages - and has only escalated since then. We've come full circle.

So the MVC paradigm was born. What it does is separate as much as possible the different languages into their own files. The model is the PHP code or what they call business logic or process. The view is the visible representation or output - HTML (with Javascript) or RSS or whatever.  The controller is the SQL or the input. Wherever possible, they've tried to keep the languages pure and separate. 

This is all well and good, except you've got PHP in all three sections. That's the glue which makes these web-apps work after all.

I think it's all a bunch of hooey. Yeah, I understand the principle, and no, I've got nothing against structured code. In fact I think it was all designed intentionally after the dot-com bust to put programmers back to work. Now you need three programmers where before you only needed one. Three times as many files to deal with.

This is supposed to make programming less complicated and more easily understood. I've worked on a few MVC packages now.  Let's say you want to fix a bug in the bogga.html web page. In the old days, you open up bogga.html with a text editor and there it is. You need to fix something - piece of cake. Now you've got to figure out what function it belongs to, and whether or not the bug is in the SQL code or the PHP code or the HTML/RSS/whatever code. Bogga.html might not even exist as a file, even though you can access it on the web. Once you've done this then you have to look through all the files to find the right place to tweak the code. Trust me, I've spent a lot of time fixing badly written code. Buggy code is buggy code. Whether or not the HTML is mixed in with the SQL doesn't make one bit of difference. All it does is take more time to find the bug - and then even more time to fix it. That's because you can't just glance at the surrounding code to see what effects a change might have anymore. The surrounding code is now spread across the filesystem. 

I  guess what it all boils down to is that if you're not multi-lingual in computer languages, you've got no business writing web-apps. If you are multi-lingual, you should be able to switch context between SQL and PHP and XHTML and XML and Javascript all within the same paragraph. Drop into assembly language to do a left shift a bit faster? Sure, why not? If this hurts your poor little brain, you've got no business writing web-apps. 

Categories: software rantings
Comments? | More Actions Open/Close menu
Back
I love you, not only for what you are, but for what I am when I am with you.
-- Roy Croft