ColdFusion Frameworks Exclusively Have Maintainable Code?
A common statement I have heard from proponents of ColdFusion frameworks, is that because it is usually easy to maintain a site built in a framework, it is also true that a site not built in a framework is hard to maintain. For those that don't know, some popular frameworks in the ColdFusion world are Fusebox, Model-Glue, and Mach-II.
Here are some facts:
- There are a lot of procedurally written sites out there that are very difficult to maintain
- There are a lot of coders that don't know Object Oriented principles
- Frameworks help people that are identified by numbers 1 and 2 (as well as other people, of course)
So, taken the above facts, can we then assume that if one doesn't use a framework, it is impossible to write scalable, reusable, maintainable code?
Well, I tried to prove in a previous post that you don't have to learn a framework to be Advanced. And likewise, I'm going to try to prove that you don't have to use a framework to write maintainable code.
If you already know Object Oriented principles, you can use a combination of cfinvoke, cffunction, CFCs, cfobject, and a few other built-in tags and functions to apply this knowledge. And, if you properly document your code, it won't be too difficult for a subsequent developer to get up to speed on your site. It is possible to separate your presentation from your logic using plain CF code. It is possible to build safe, secure, portable objects using plain old CF. It is also possible to use encapsulation, abstraction, inheritance, and other OO concepts.
All this said, I do think frameworks are filling a big need in the CF community. I'm definitely not trying to discourage anyone from learning a framework. I just don't believe that framework developers and users have exclusive rights to Object Oriented code. However, I'm pretty much on the fence as to whether or not I'll learn and use a framework. I've played with Model-Glue, but there are still a few things I'm not comfortable with in the CF frameworks available today. But that's another blog post.
Jake Munson
35 Yrs old

Now, whether an advanced programmer knows they use a methodology is another question. Some may not because they may not look for it, may not care enough, whatever it is I bet they use one though.
Frameworks are really just methodologies taken to the next level with some functions automated by code.
Benefits of a community framework for an advanced developer are easier code sharing and quicker ramp up for new hires who may already know a community framework. You also get to leverage other peoples code pretty efficiently.
Downside is that frameworks do things their way and if you don't like that, there are some things you can change and some things you can't. Personally I don't use frameworks, but there are elements from a number of frameworks (from shared scoping of URL and form variables through Inversion of Control patterns) that I happen to use.
I do think it is worthwhile for any advanced developer to learn about the major frameworks. Whether you learn about XFA's or even the concept of the rules engine in Tartan (if not it's implementation), there is always something to learn.
A lot of the patterns like IoC/DI and Factory patterns are exhaustively documented elsewhere outside of the CF community, but having some working code to review helps to cement the learning process.
Just my 2c
Best Wishes,
Peter
I personally wouldn't touch a framework for the following reasons.
1. There is nothing you can't achieve with CFC's alone
2. Adobe might release more OO features in V8
3. There is no guarentee of ongoing support of these frameworks.
In developing real world commercial applications, I prefer to rely on what Adobe give me.
The benefit of open source is that you have access to the code, so if everyone else in the world moves onto something else, YOU can still maintain and develop the code. This still gives you the benefit of other peoples code to get started, but none of the benefits of ongoing input from others.
If you're a community framework kind of person, you'll probably find yourself porting active sites to new frameworks or versions of frameworks every 3-5 years (guestimate).
My point exactly, there are heaps of good ideas out there with a handful of people using them, and sure it's open source, but who wants to debug and maintain a large complex framework that you didnt write.
I've got better things to do, and as I said you can do it all using cfc's anyway.
Say you develop a large site with a framework. Later you find out the framework now has some important bug fixes, and some cool new features. How easy is it to upgrade?
This is a problem I have with this blog. While I really like BlogCFC, every time Ray puts out an upgrade I've got a largish job ahead of me to upgrade my blog. You can't just throw the new core files in and run with it, there's the blog layout files, integrating code tweaks, not to mention DB updates (the latter is not a problem with the frameworks).
I know the framework developers probably try to maintain backwards compatibility, but as with all software, if you're going to move forward, you've got to make changes that will affect previous versions.
I speak pretty much daily with those writing ColdSpring, Reactor, and Fusebox 5. I don't think a single one of us would ever say that because an app doesn't use a framework than it must, therefore, be difficult to maintain.
It's easy to write a somewhat OO ColdFusion application by placing business logic into CFCs and calling them at the top of your pages, or using your own homebrew pipe-and-filter approach.
It's a lot harder to have both the experience and maturity to recognize problems with the specific portions of your own application (like flow of control or dependency resolution) where frameworks can help.
"Just because members of one set (framework-based applications) are members of another (maintainable application), nothing prevents members of a third set (non-framework applications) from being part of the second (maintainable applications)."
You will see this post as a 'troll' because you are firmly in the frameworks camp, purely by nature of being a framework author. However, I'm just reflecting what I've seen. There are a lot of people in the framework community that have become very snobbish about their 'elevated status' as CF developers. Here is a direct quote from a recent cf-talk thread: "I can make any FB application have better performance characteristics by ripping out the FB. I just won't be able to modify it tomorrow with any sort of effectiveness..." So the author's belief is that you have to use Fusebox in order to have maintainable code. This comment, and others I've seen like it, are what prompted me to write this blog entry.
In your comment you said, "It's a lot harder to have both the experience and maturity to recognize problems with the specific portions of your own application (like flow of control or dependency resolution) where frameworks can help." This comment is similar to the above, because you are saying that people that don't use frameworks have a hard time achieving the level that frameworks give you. While I'll agree that there are some CF coders that don't "have both the experience and maturity" to code at this level, I'd argue that there are a lot more experienced coders than you'd think. And it's just as easy for such an experienced coder to use their own OO techniques as it is for them to adapt a framework.
And, like I said in my blog entry, I am /not/ saying that frameworks are bad, or that they should be avoided. I've just heard snobbish comments from framework users one too many times recently.
> firmly in the frameworks camp, purely by nature of
> being a framework author.
I'm not sure it's a good idea to state another person's reasoning unless you're a mindreader. I saw at as a "troll" post purely because it used a controversial headline that was founded on a logical fallacy.
According to your logic, a person stating that frameworks make applications more maintainable means that they also believe that no non-framework application is maintainable. That's simply a boolean error any programmer with her/his salt can spot. It's like saying that because all Oranges are Fruits no Apples can be Fruits, and I take offense to it: I'm obviously a big fan of frameworks, but I think it's perfectly possible to write a maintainable app without a framework. It's just more difficult to do so.
Barney's quote on CF-Talk ("I can make any FB application have better performance characteristics by ripping out the FB. I just won't be able to modify it tomorrow with any sort of effectiveness...") concerned framework overhead and performance. His point was that by throwing out the framework, you'd get fractionally better performance (FB is faaaaast) at the expense of modularity and maintainability. That's just common sense. He's not making a claim that "you have to use Fusebox in order to have maintainable code."
> In your comment you said, "It's a lot harder to have
> both the experience and maturity to recognize problems
> with the specific portions of your own application (
> like flow of control or dependency resolution) where
> frameworks can help." This comment is similar to the
> above, because you are saying that people that don't
> use frameworks have a hard time achieving the level that
> frameworks give you.
"Achieving the level?" I'm not sure what you mean here, and I'm not certain you understood what I said. I'm certainly not saying that people who don't use frameworks can't achieve high levels of experience and maturity - that's absolutely absurd.
What that statement means, broken down, is that it takes a certain degree of pragmatism combined with software architecure experience to recognize the problem sectors of a given application's architecture, and that it's a lot harder to do that than it is to write CFCs and call them at the top of a page. If I had to sum up what I feel separates an "architect" from a "developer," it's the ability to think in this manner. I've learned this through personal experience - it's common knowledge that I was anti-framework for a long time, and that my apps were nothing but collections of .CFM pages that called CFCs for their business logic.
> it's just as easy for such an experienced coder to
> use their own OO techniques as it is for them to adapt a
> framework.
That's an odd statement. OO techniques are entirely different from frameworks. I'd say it's a *lot harder* to learn good OO than it is to use a framework. Heck, I wrote a framework, and I'm still learning OO. One of Sean's favorite quotes is something like "I've been doing it for twenty years and I'm still learning - it's hard stuff!"
{waits for 'Hi, Scott!'}
I don't think using frameworks vs not using frameworks is any better in general. However, it is better for me.
I have seen horrendous non-frameworked applications and I have seen horrendous frameworked applications.
I have seen wonderful non-frameworked applications and I have seen wonderful frameworked applications.
I agree, if the methodolgy is sound, odds are the application will be maintainable. Frameworks, for me, help with the methodology.
First, I want to reiterate the point that seems to be getting lost here, that I'm not attacking frameworks. I truly think frameworks are filling a need in the CF community, and I'm planning to use one for my next project. This has turned into a framework vs. nonframework argument, and that was not my intention /at all/.
Now, as far as Barney's quote and your response to it. Here's a snip, "His point was that by throwing out the framework, you'd get fractionally better performance (FB is faaaaast) at the expense of modularity and maintainability. That's just common sense." You are saying /exactly/ the same thing that I'm arguing against. According to what you just said, and a what I've heard from other framework fans out there, it's "common sense" that not using a framework is a decision made "at the expense of modularity and maintainability". Maybe that makes sense to you, but not me. I am not putting the words into the mouths of framework users, it's what I've heard and I'm just repeating it.
That said, I do think that there are a LOT of CF coders that don't write modular, maintainable code, and don't really know how if they wanted to. Frameworks are an excellent tool for them. They can also be an excellent tool for the experienced folks that /do/ know how to write maintainable code, because there are a lot of tools in these frameworks that can't be easily duplicated. In fact, I've been pretty impressed with the stuff I've been hearing about the next MG, Unity, like the Action Packs. It's hard to beat drag 'n drop applications. :)
I agree, that is the perception. And with a lot of blog posts out there that talk about skill divides in the CF community, where using a framework is one of the measuring sticks, I think the message is pretty clear. Again, I'm not saying that frameworks are bad, but there is a lot of snobbery coming from the framework camp, particularly in the mailing lists.
Jacob is right: you *can* write maintainable OO code without a framework. I don't actually think anyone is arguing with that.
Several people have said it's *harder* to write maintainable OO code without a framework and I don't think anyone is actually arguing with that either. Well, Simon Horwith hasn't commented on this thread yet :)
Writing maintainable OO code - writing maintainable code in any style - is non-trivial and something that takes people time to learn. Many people believe frameworks make that task easier (perhaps consider them lazy people: they want assistance writing maintainable code?).
A *few* people may believe that if you don't use a framework, you're condemned to a world full of bad code. They're wrong (of course).
And the flip side is just because you use a framework doesn't automatically mean your code will be maintainable. You can write bad code with any framework. You can write bad code in any language.
I don't think Jacob's post was controversial - to me, it's kind of "Well, duh!", as was his previous post on this topic. Which is why I didn't respond until this framework vs no-framework discussion got going and I felt it worth saying:
I'm a huge fan of frameworks but Jacob is right.
Word.
Until these frameworks are polished enough to give acceptable load times, I will continue to develope my way: I basically use BEANS, BO, DAO and then one big CFC for the application methods leveraging all classes. This way cuts down on my development time, increasing the enforcement of business rules, increases the speed of page rendering, is maintainable and extensible.
Yes, the frameworks have been load tested. Model-Glue has been load tested extensively. If you'd really like to bet your life that Model-Glue will quadruple your page execution time (or M2, or especially FB), I hope you've made your peace with Dog.
I agree, my post is kind of a 'Well, Duh!' statement. I didn't really think this was going to be so controversial when I wrote it, but I guess it is. I think the problem is that I said, "A common statement I have heard from proponents of ColdFusion frameworks..." which is kind of a blanket statement. Usually when I've seen statements like I mentioned in my original post, it's of a heated frameworks debate, and a lot of logic goes out the window as the emotion settles in.
But it's not usually people like Joe or Hal Helms making these statments. However, I did hear Matt and Peter saying that non-frameworked code is not easily maintainable in Version 1.9 of the ColdFusion Weekly podcast. They were talking about the benefits of frameworks, and here is a quote, "(Peter) [A framework] can really save you time, especially with maintenance...(Mark) The big, big benefit of writing things in a framework is the maintenance aspect of it."
Are Matt and Peter saying that non-frameworked code is hard to maintain? Not directly, but if you are pushing maintainability as a big benefit of using frameworks, the implication is that you can't get that elsewhere; otherwise, why is it a benefit?
If I say the benefit of a certain model car is good gas mileage, does that mean other cars don't have good gas mileage. It does mean that compared to the average car, it gets good gas mileage.
Likewise compared to the average application, a frameworked one is easier to maintain. Now that may be an unfair statement because nobody can look at all CF applications and judge their 'ease of maintainability'.
I would say that for a person like myself - who doesn't have a programming background and is a newbie to the OO style - coming up with my own methodology and creating low maintanence components is harder to do on my own versus learning a framework.
I consider myself a frameworks noob, but I have found that using a framework does improve the organization and maintainability of my code. I have found that it provides a level of underlying documentation that would make it easier for another programmer unfamiliar with my work to come in and grasp what I was doing. My decision to use a framework and to recommend my experience to others has nothing to do with you personally...I know nothing about how you code; I have never seen any of your work. Therefore, if I were to speak of my perceived benefits of using a framework, it would be more a comment on my prior non-framework code, not yours, so there really isn't such a need to get so defensive.
I think also the discussion of skill divides isn't IMHO about whether you choose to use a framework or not. Again I think you are reading into things. I read and studied frameworks long before I ever chose to adopt one (for instance, I have read the Fusebox books but never actually used Fusebox). However, because I showed an interest in the best practices and recommendation of others I could either choose to use or not use a framework from an informed position. I think the skill divide lies in the number of people who don't even know that CF frameworks exist, nor any other issues that are prominent topics within the overall ColdFusion community. So, again, this discussion isn't directed at you and I believe has nothing to do with your choice not to use a framework.
Jacob - stop putting words in people's mouths. No one is saying you CAN'T write maintainable code without a standardized framework - people are saying that it's EASIER. The thing EVERYONE needs to realize is that EVERYONE uses frameworks. Either it's a documented, tested, and community-supported one, or it's the one you cooked up on your own. Usually those who cook up their own don't know what they're doing - Tony is a great example - he thinks one class that handles everything is an example of "maintainable" and "extensible" code.
And I'm going to say another thing one more time, I'm not saying that frameworks are bad and I'll never use one. I fully intend to use one here soon, as soon as I have time to start my next project.
If you guys were to dig around on cf-talk a bit, and find /any/ discussion about frameworks, I'm sure you'll find a thread where things got heated. If you take an objective view point for a minute, it's not hard to find people on both sides of the argument that make incorrect blanket statements. And yes, there have been times that framework proponents have said the things that I started discussing here (in fact, I posted a direct quote in an earlier comment).
In my opinion maintainability comes down to three things
1) indenting code
2) small file sizes
3) how intimate the programmers are with the code
Frameworks help with that third item above.
I've been using CF since version 3, I work on some pretty big and complex projects but I have never used a framework. I don't have any idealogical problems with using them, in fact I would love to be up to speed with FB, MG etc and every few months I go off to the websites to see what the latest developments are.
The problem is that they are all to complex, I just don't have the time to sit down and work out how to use them - they might save me time in the long run but I just can't take the vertical learning curve at the beginning.
I want a framework which I could introduce to the team I work with in a 15 minute presentation, the team consists of coders off all standards but they should all be able to get a firm grasp of what it does, why it does it and how to use it in that 15 minutes.
The attraction of CF has always been it's simplicity of use and its easy learning curve, what I would like to see is a framework which has the same ease of use.
Your application has 3 top level folders: Controller, Model, View
In your view folder you have subfolders, example: "users". In the Users folder you have 1 cfc: users.cfc and a bunch of display cfm files. The cffunctions in the cfc include one or more cfm. Example function: "LoginForm" that function includes: dsp_LoginForm.cfm
In your model folder you hve subfolders, example: "users". In this Users folder you have 1 cfc: users.cfc and a bunch of QRY/action cfm files. Like the view folder, the cffunctions include one or more cfm files. Example function: "validateLogin" that includes: act_validateLogin.cfm
Finally you have a controller folder with subfolders. example: "Users". In this users folder you have 1 cfc users.cfc and NO cfms. The cffunctions here cfinvoke functions from either model, view or other controller Objects.
controller cfcs only do cfinvokes, model and views only do cfincludes. All 'real' logic/UI code is stored in the cfms. There are a few details with regards to passing data around, but that's about it.
What do you think? Is this still too complex? I can't tell anymore because i'm so used to working like this.
I think I could live with that. But one thing I've never been able to understand is why the controller part of MVC is necessary. I can understand why it's good to separate the model from the view, but the controller seems like an unnecessary complexity, at least to me.
<cffunction name="Receipt">
<cfinvoke component="#application.model.Orders#" method="getOrder" argumentcollection="#arguments#" returnvariable="arguments.getOrder"/>
<cfinvoke component="#application.view.Orders#" method="ViewReceipt" argumentcollection="#arguments#" returnvariable="arguments.body" />
<cfinvoke component="#application.view.Layouts#" method="masterLayout" argumentcollection="#arguments#" />
</cffunction>
<cffunction name="PrintableReceipt">
<cfinvoke component="#application.model.Orders#" method="getOrder" argumentcollection="#arguments#" returnvariable="arguments.getOrder"/>
<cfinvoke component="#application.view.Orders#" method="ViewReceipt" argumentcollection="#arguments#"/>
</cffunction>
In the first function it calls 3 methods. The first one gets the order from the database (model CFC) and puts that query into #arguments.getOrder#. The second one loops over that query and creates some HTML. Now it doesn't immediately output the HTML to the screen, instead it puts the HTML into a string variable called #arguments.body#. Finally it calls another view template that contains the site layout. That cfoutputs the body variable inside some more html allowing for a nested layout.
Now the second function calls the same first two methods, but it doesn't call the layout method. So with relative ease we can change the UI without changing the original page. Does that sort of make sense?
The same thing can be done with action code. Here's another example:
<cffunction name="editaddress">
<cfargument name="AddressId"/>
<cfinvoke component="#application.model.users#" method="getaddress" argumentcollection="#arguments#" returnvariable="arguments.getaddress"/>
<cfinvoke component="#application.view.users#" method="editaddress" argumentcollection="#arguments#"/>
</cffunction>
<cffunction name="ViewReceipt">
<cfargument name="BillingAddressId"/>
<cfargument name="ShippingAddressId"/>
<cfset arguments.addressId=BillingAddressId>
<cfinvoke component="#application.model.users#" method="getaddress" argumentcollection="#arguments#" returnvariable="arguments.getShippingAddress"/>
<cfset arguments.addressId=ShippingAddressId>
<cfinvoke component="#application.model.users#" method="getaddress" argumentcollection="#arguments#" returnvariable="arguments.getBillingAddress"/>
<cfinvoke component="#application.view.orders#" method="ViewReceipt" argumentcollection="#arguments#"/>
</cffunction>
In the first function it gets an address then populates a form for editing that address. Can you picture it? Now the second function calls the getAddress twice. The first time it calls it it sets the addressId=billingAddressId, the second time it sets it to shippingAddressId. Both getShippingAddress and getBillingAddress are then passed into the viewRecipt User Interface.
Think of it like this... The model and view Methods are puzzle pieces. The Controller Methods are completed puzzles.
I need to go read about MVC some more. I can understand your examples, and they make sense. But I can also see how it's possible to use an MV framework without any problems. But I'll study up and try to understand it. :)
I suppose this is how some of the other frameworks started out, but then somebody adds a bit of "cool" functionality here, somebody else wants to do something slightly different there, and before you know it you are several versions down the line with a product that can do almost anything but has 500 pages of docs needed to describe how to apply it.
It would be nice if there was an alternative where the primary requirements during development was usability and simplicity. It would also be nice if you could use a basic system then add other functionality in some sort of modular way if needed, so the learning curve was as shallow as possible.
It hasn't always been a matter of 'cool' it was a matter of language availability. But you do have a point, there is definitely a little too much 'cool' in most frameworks.
I agree, it's not wise to focus only on a single idea. I'm not sure that's what I'm doing though, I'm just stating my untested theory that the 'C' isn't as important as most people think.
Speaking of focusing on a single idea, it seems to me that's what's happening with these frameworks anyway. People get it in their head that in order to be an 'advanced' CF programmer, you have to use an MVC framework. Forget about security, SEO, usability, good DB design, etc. I know and use a framework, and that makes me an expert CF programmer! I know most people don't do that, but it's something I've seen around in the lists and blogs.
Without the controller (and again, it does not necessarily need to be a seperate file), you application wouldn't do anything. Even with spaghetti code, there is logic in each page, though admittedly, it scattered throughout the page, that ceould be considered, at the very least, controller-like.
In addition, I have seen clients add developers to a project more quickly and effectively when a recognized non-deviated Framework is used which that developer knows well.
Lastly and as something for all of us as developers to consider. If we truly know a recognized non-deviated Framework(s) we increase our worth to clients and our earning potential. I can tell you from working with medium and large corporations that those corporations are largely not interested in some home-grown Framework, no matter how forcefully the creator may tout it. However, they are interested in recognized Frameworks for the reasons stated above.
I am curious why you choose to use <cfmodule> for you method calls I used to do it this way, but switched to using <cfset object.method(argumenst) />. It just seems cleaner to me (and, most of the time, would save me some keystrokes).
I think you're right. That's one of the big benefits of using frameworks. My only problem with that argument is that there are a lot of frameworks out there today (a new one announced just this week!). It's only a small percentage of the CF population that uses one particular framework.
Now, it's still beneficial though, because you're using a framework that's documented. But you could also have your own documented methodology, and have the same effect. So that argument's out the window. So the only real benefit (of this type, I know there are other benefits) is that there's a small chance that the subsequent developer will be familiar with the framework you used.
I /really/ wish all of the MVC experts out there (Joe, Sean, Hal, Matt Woodward, etc.) would throw their respective frameworks in the trash and pool their resources to make one killer, /standard/ MVC framework. But it'll never happen.
Jacob, Dale, Sam, Wayne and all those that don't use frameworks but use methodologies for maintainable code, do any of you know of any tutorial/documentation/example resources that delve in detail into maintainable code without frameworks. If no one knows of anything, this could be a place to start to get a resource out there that could expand on a methodology that starts with simplicity as CF does; uses all the resources Adobe has available within CF, and gets most of the benefits of a framework without the complexity.
I agree, that would be very nice. I know Simon Horwith has his methodology somewhat published, calle SAM (I can't remember what it stands for). It's not a framework, just a set of OO oriented practices. If you look at the CF Petmarket site, you can see an example of it, but I'm not sure if he's ever actually formally published it.
I started writing a response here and it turned into a whole blog post! So I posted it on my blog with a link to your site. The URL for the blog posting is:
http://www.web-relevant.com/blogs/cfobjective/inde...
Let me know what you think?
Thanks,
J
It gets pretty offensive sometimes.
I persoanlly wish the great minds of our community would quit ranting about wether or ot a framework is good and move on to better OO/CFC/model development.
I already know when and where I will use one of framework(or not) and NO ONE OUT THERE can change my mind.
Can we PLEASE start talking about something more productive than this year old topic.
I respect all of you guys VERY much. I couldnt have gotten where I am today without you all. But this converstion is getting VERY OLD.