Subscribe Now: freedictionary

Add to The Free Dictionary

Tuesday, 13 March 2012

MVC

I don't have much of a problem with MVC itself. It's the framework baggage that usually comes along with it that I avoid. Parts of frameworks can be useful as long as you can separate the parts out that you need. As for MVC, if you use it carefully, it can be useful in a web application. Just make sure you avoid the temptation of creating a single monolithic controller. A web application by its very nature is a series of small discrete requests. If you send all of your requests through a single controller on a single machine you have just defeated this very important architecture. Discreteness gives you scalability and modularity. You can break large problems up into a series of very small and modular solutions and you can deploy these across as many servers as you like. You need to tie them together to some extent most likely through some backend datastore, but keep them as separate as possible. This means you want your views and controllers very close to each other and you want to keep your controllers as small as possible. Goals for this approach Clean and simple design HTML should look like HTML Keep the PHP code in the views extremely simple: function calls, simple loops and variable substitutions should be all you need Secure Input validation using pecl/filter as a data firewall When possible, avoid layers and other complexities to make code easier to audit Fast Avoid include_once and require_once Use APC and apc_store/apc_fetch for caching data that rarely changes Stay with procedural style unless something is truly an object Avoid locks at all costs

No comments:

Post a Comment

comment.........

Engineering -Thinks of Words

Subscribe Now: google

Add to Google Reader or Homepage