If you look up the definition of MVC or Model View Controller, it will hail the definition as being able to change your front end without affecting other parts of the application and vice versa. This sounds great in theory, however this claim is nothing more than a blatant lie.
A failing of the architectural pattern comes from the whole codebase being tied to a specific stack. Take ASP.NET MVC. The domain logic will most likely be in C#. Therefore your models will be in C#. Your controllers will be in C#. Your views will be a mixture of C# and some form of a templating language.
If you want to change your stack to the “next big thing” you are forced to take a big bang approach. ASP.NET MVC won’t be around forever. Being tied to a specific technology feels wrong. Therefore this coupling means your designers are forced to use the templating language that your framework supports. This should be a flexible option that should be easy to change, after all the MVC pattern states this as one of it’s benefits.
Being tied to a specific technology leads onto our most recent project. One of our biggest and most important projects is a legacy Flash application. Back in the early 2000′s it was a cutting edge application – consistent across all browsers, ajax style requests, responsive design, you name it.
That being said we all know Flash is on its way out, and there lies the problem. It took myself about two weeks to add a few text boxes to the app in my first year at Codeweavers, all because the UI code is so difficult to work with. The logic is mixed within the UI. Had the app been developed in a MVC style we would be in a position to replace the legacy UI with a modern alternative.
We make use of SOA or Service Oriented Architecture at Codeweavers, therefore it seemed a natural fit to apply this to our rewrite of our legacy application. I proposed a theory:
“for an application to be truly independent of the frontend and backend the code must be developed in different languages.”
For example, I taught myself enough PHP to make a JSON request, perform some conditional logic and loop over a collection. With this I was able to recreate one of our applications that was powered by our backend C# services. I would not want to create an application in PHP, but using PHP as a templating language was a great fit. Afterall this is one of the intentions of the language. Limiting myself to just three simple PHP constructs I was forced to put all logic on the service in question.
This complete separation of concerns is made possible due to the fact it is simply not possible for code to leak between the layers due to the different languages used in the implementation. This means I could easily spin up numerous front end views while the backend remains unchanged. Likewise we could change the back end implementation from C# to another language. Providing the endpoints and request/responses match, the front end will still be functional. This full separation of concerns is what MVC style frameworks have failed to achieve.
In ten years from now it is hard to say what the web will look like. What I can guarantee is that the web will still be here. We’ll still be making HTTP requests. We’ll still be making back end services that powers much of the apps on the internet. One thing no one can really comment on is what the web will look like. One point we all could agree on is that HTML5 should be wide spread and no doubt “the next big thing” will be on the horizon. The great thing by taking the approach discussed previously is that Codeweavers will be in the position to change either the front end or back end of our codebase at any time. Precisely what the MVC pattern has failed to deliver.
Image by lynnepet (Creative Commons)




Previous Page
Not trying to be an asshat but “must be wrote” in your quote up there strikes me as incorrect?
No worries. Thanks for the feedback. I’ve edited this.
“This full separation of concerns is what MVC style frameworks have failed to achieve.”
…
“MVC is Broken”
I’m going to go out on a limb here, and guess, from the grandiose statements here, that you’re still (relatively) young and you’re still learning an awful lot about programming right now. I say this only because I went through a similar thing in my early twenties. Only as you gain experience do you see why things were done the way they were. Obviously, that blissful ignorance of youth is also what allows young people to change the world, so please don’t think I’m being judgmental or cynical. I wish I could get some of that back.
MVC is not really broken. It was never meant for distributing components across the network. What you have ‘discovered’ is in fact already well established and you’d usually call it a Distributed System, or maybe n-tier if you like that kind of thing.
MVC came about to stop people from creating spaghetti code full of side-effects in their interfaces. See if you can find the source to a legacy VB6 app and you’ll know instantly what I mean. It was never meant to enable disconnect between languages and platforms.
I think these days, what you are describing is best called an API. Your back end is an API, and your front-end is a separate system. I really like this way of doing things, because it fits the app-on-a-phone model really well but also because it makes the back-end extremely easy to test.
As it happens, people who are using Rails for MVC web apps are kind of doing this already. All of those respond_to.json’s scattered throughout your (hopefully skinny) controllers mean you already have an API. You HTML pages are ERB or whatever, but it is so so easy to swap out the View portion for, say, an iPhone app using AFNetwork and some glue.
If you really want to get in to distributed systems, you might like to take a look at message queues. RabbitMQ is very good. Message queues open up whole new worlds of possibilities (for example, right now your view is blocked while it waits for the controller to respond over HTTP. With queues, you can work around that and go for extreme performance.)
Thanks for the comment Adrian.
This is exactly what I was trying to get across. I am not claiming to have invented anything, I’m simply trying to point out that what you mentioned above is the ideal way to develop web apps. I’m well aware of the benefits of MVC for simple applications, but for anything that has a serious shelf life it starts falling apart if developed in the same language/framework.
Using Rails as an example, part of the problem with this pattern is the whole stack will be a Rails app. In my (and others opinion) you should have the Rails app power the back end – while the front end is driven via something else. Again, this is nothing new.
Hope this clears things up.
Just to add to Adrians comments. From my understanding of MVC the separation is not about different technologies per se. I think it’s just about separating concerns. Now having said that, I know for instance with almost all MVC frameworks I have used (not that many if I may add) Zend (PHP), Play (Scala), Django (Python) the concern is not about doing the front end in language a or language b, it’s the fact that you don’t have to touch the front end when you need to do serious back end stuff and you don’t need to worry about front end people playing hero with backend stuff. I believe that is the Philosophy behind MVC.
This is not to be confused with distributed computing under which SOA falls. API requests, etc are a function of that distribution and not the design pattern used at the middle ware level of which you can classify these MCV frameworks (rails, zend, play, lift codeigniter etc). I think in designing your infrastructure these distinctions have to be made early.
.NET MVC is MVC as long as the back end is .NET. What you’ve discovered isn’t some fault in MVC methodology. It’s the proprietary nature of Microsoft and most other for-profit vendors. Obviously Microsoft has a vested interest in insuring your app stays in .NET technology.
However, I agree that MVC isn’t the end all … a separate front end from an API accessed back end is the future of all web development. That way an iPhone app, Android app, mobile site, desktop site and any other services can access your app’s data from a single point. What you’re seeking is a different methodology.