ColdFusion and Frameworks I touched on the subject a little bit, but didn't go into any more detail because that Blog Post was not about this problem. Since that entry on my Blog I have had a lot of discussions on this subject, and I thought it would be better to dedicate an entire post on the subject.

"> Should ColdFusion adopt an MVC pattern

Should ColdFusion adopt an MVC pattern

The short answer is yes they should, but the reality is that it might be too late for ColdFusion to do this. In my last blog entry ColdFusion and Frameworks I touched on the subject a little bit, but didn't go into any more detail because that Blog Post was not about this problem. Since that entry on my Blog I have had a lot of discussions on this subject, and I thought it would be better to dedicate an entire post on the subject.

Now before I go into this with some more detail, lets go back to the beginning for a moment and have a look at how the whole design process to development on the web has changed overtime. In the very early days of ColdFusion the language was created to provide a simplistic approach to integrating the html with databases, and since then it has evolved with many patterns and methodologies. The one thing that hasn't changed is the way ColdFusion servers and integrates with the a page request, and this could be the downfall that could make ColdFusion too hard to change as it evolves over time.

To help explain this some more, for those who might be reading this and are not aware of what an MVC pattern  actually is. The MVC pattern has become a widely used pattern, that envisages three main components; The model, the controller and the view. Which is used to separate and application's data model, user interface and control logic. In which they can be described as:mvc-original

  • The model: A domain specific representation of information. The information itself is usually stored persistently (e.g. in a database or in a file). The model adds meaning to this data by providing mechanism to work with it.
  • The view: This is the component that presents the data held by the model to the user. This is typically a user interface element. Several views can access the same model data and represent it.
  • The controller: This is the component that receives events (such as a click on a menu item) and processes them. It invokes changes on the model, and sometimes also on the view.

Over time ColdFusion framework authors have implemented their own versions of this pattern, with varying degrees on how they work internally to suite the application framework. But the one thing in common to all of these frameworks, is that they all adopt the standard MVC pattern. The biggest benefits to using this pattern over the conventional way ColdFusion does page requests, is that every file under the websites root directory can be served. And that leads to more problems to developers, and most of the time this problem will never surface or even be a consideration when it comes to designing the application in question.

So why is it a problem then? Well lets take Fusebox as an example to help illustrate this point, the last version of Fusebox that I had or was exposed too. Had not concept of security rules, or even a true concept of the above pattern. It had a very basic implementation, that works and works very well. But at the end of the day any of the code in the circuits, or in other parts of the site can be called without going through the main entry point for each circuit. That can cause more serious problems!

Now I am a huge fan of ColdBox and began using it before some of the others began to adopt the rules based security, and find it now to hard to just switch between one framework and another. And after seeing the amount of work that is needed to move between one framework and another, inspired me to make the last post on ColdFusion and Frameworks and maybe get a few authors conspiring to create a standard or best practice to allow for one to achieve that. Because at the end of the day no matter which way you look at it, MVC is a pattern and is not the entire framework architecture that most people seem to not see for the forest, and there is no reason why these authors can't cant get together and agree on a standard that would make it easier for people to switch between one framework and another. Which leads me back too...

ColdFusion and the MVC pattern could easily be integrated into the CFML engine, in the same manner that RoR and Grails have done. I am not saying that it would be easy to achieve at the moment, because there are a lot of other factors that come into play as well. And the most important factor in this equation comes from Adobe themselves, and they aren't making it any easier with each new release, In fact they are making it harder and harder, when they should be making it easier and easier.

The solution as I see it is to take the current frameworks and create a standard MVC pattern, that could be taken away from these frameworks and incorporated in ColdFusion and allow these authors to concentrate on expanding the framework in areas that they need to.



  • John Farrar's Gravatar No it should not... development frameworks should be supported but they are not needed IMO to be official Adobe frameworks. (Of course then I will admit the IDE might perhaps offer better direct support, eh)

    Also, MVC is not the pattern we use on the web. We use something more like what they call Model 2. Our apps call front controllers that intereact with sort of a MVsC (Model - View - sub Controller). It would be pretty difficult to build a 'real' MVC pattern. So why do I bring that up? It is because this type of thing would turn into a debate about the quality of "Adobe's Framework" and ColdFusion developers have some great framewords already. We may need some better work on frameworks and I for one and going to show off what we have been doing with SOS at CFUnited this summer. Hope to seem many of you guys out there this summer.
    # Posted By John Farrar | 3/31/09 5:56 AM
  • Andrew Scott's Gravatar MVC is not a framework, and with your logic then Hibernate should never be apart of the core of ColdFusion either. I think if you read what I said with a bit more understanding, I think you will find that it is possible for framework authors to use a configurable MVC pattern and still be able to do what they do best.
    # Posted By Andrew Scott | 3/31/09 6:09 AM
  • Kyle's Gravatar Do you think you could give a better example of what you mean? I think the language should be pattern independent, but you may have a point if I only understood what you meant.
    # Posted By Kyle | 3/31/09 7:24 AM
  • Matt Woodward's Gravatar What we're running into here is the blurring (or maybe it's an unblurring?) of the line between CFML as a language and ColdFusion as a framework/product. With the work of the CFML Advisory Committee this distinction will become more clear over time.

    Bottom line is that when you say ColdFusion could/should do what RoR and Grails have done, you're equating ColdFusion to frameworks. In my mind that's fine--so long as there's a clear distinction between the language itself and what a particular framework decides to do on top of that language.
    # Posted By Matt Woodward | 3/31/09 7:38 AM
  • Andrew Scott's Gravatar @Matt - No I did not say that ColdFusion could/should do what grails and RoR have done. But I think that the distinction should be made as you pointed out, but the burning question is that there is by far too many entry points into ColdFusion. An MVC pattern would eliminate that, but for it to work it would be needed to be standardised that allows for current framework authors to leverage from as well.
    # Posted By Andrew Scott | 3/31/09 8:08 AM
  • Henry Ho's Gravatar "The biggest benefits to using this pattern over the conventional way ColdFusion does page requests, is that every file under the websites root directory can be served. And that leads to more problems to developers, and most of the time this problem will never surface or even be a consideration when it comes to designing the application in question."

    Urr... so where is the problem exactly? I don't quite get what you mean.
    # Posted By Henry Ho | 3/31/09 10:01 AM