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.

Related Blog Entries

Comments
Great points. Frameworks are styles of using good design principles. If the good design principles are in place in an application but the style isn't documented then many don't realize that still works. (What makes an application stable isn't the documentation of the programming standards, but the implementation!)
# Posted By John Farrar | 6/7/06 8:26 AM
Have you checked out ColdFusion on Wheels yet?? http://www.cfwheels.com I consider it to be "the framework for the rest of us." Mach-II, Model-Glue and them seem way too academic for a "normal" CF programmer -- someone who started with CF because it was easy to develop things quickly. While Wheels relies on OO stuff behind the scenes to keep everything organized, you don't need to worry about it too much yourself, you just get to write code and have fun! There are a couple of good video tutorials on there and some written docs as well. 0.5 will hopefully be out this week with everyone's favorite feature, scaffolding!
# Posted By Rob Cameron | 6/7/06 9:58 AM
Rob, no I haven't tried it yet, but I've heard of it. I'll have to check it out.
# Posted By yacoubean | 6/7/06 12:47 PM
I think its fair to say that an advanced programmer will have some of methodology. Code developed with a methodology is generally much easier to maintain than without.

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.
# Posted By Sam Farmer | 6/7/06 1:55 PM
I would argue that most advanced developers who develop a large number of sites (as opposed to those responsible for ongoing maintainance of one or two in-house sites) use a framework. Some of them use a community framework like fusebox or Mach-II. Others have rolled their own.

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
# Posted By Peter Bell | 6/7/06 3:06 PM
Some of you are commenting about off topic (close but the target but your on a tangent conversation to the focus of the post). His point was that it doesn't take a framwork that is layed out as a framework to be good code.
# Posted By John Farrar | 6/7/06 3:15 PM
Thanks John, I mostly agree. But I think Peter's and Sam's remarks kind of prove my point, because both of them talk about using advanced OO techniques without using a framework.
# Posted By yacoubean | 6/7/06 6:31 PM
Good post,

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.
# Posted By Dale Fraser | 6/8/06 3:09 AM
Isn't that the benefit of open source? You don't need to worry about some corporation going out of business and not supporting your platform anymore. It's supported automatically by the people that use it.
# Posted By Rob Cameron | 6/8/06 10:02 AM
Not really, have you looked at all the "living dead" projects on SourceForge recently?

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).
# Posted By Peter Bell | 6/8/06 10:10 AM
Yeah,

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.
# Posted By Dale Fraser | 6/8/06 5:22 PM
Since we're firmly on the the topic of framework vs. non-framework, which as John pointed out wasn't my original intent with this post, I'll add another point. :)

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.
# Posted By yacoubean | 6/8/06 7:10 PM
If this were /., I'd give the post a +1 Troll just on the basis of a headline. Its title is argumentative and based on some fairly flawed logic. Just because members of one set (framework-based applications) are members of another (maintainable application), members of a third set (non-framework applications) from being part of the second (maintainable applications). That's pretty basic Logic 101.

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.
# Posted By Joe Rinehart | 6/11/06 8:50 AM
Second sentence should read:

"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)."
# Posted By Joe Rinehart | 6/11/06 8:51 AM
Joe,

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.
# Posted By yacoubean | 6/11/06 10:04 AM
These threads are always stimulating and mildly or overtly controvertial. I have spent the past 7 years traveling the world helping mainly ColdFusion and some JRun users to find and fix application perormance issues. If I can pick up what is going on in the code more quickly, the client benefits. Whilst it is true that a recognized framework does not guarantee good code it is also very true that a properly used recognized framework instills a recognized order into application development across disparate clients. I have not found nor can think of any valid points as to why recognized frameworks should not be used in coding all web applications.
# Posted By Mike Brunt | 6/11/06 2:15 PM
"I have not found nor can think of any valid points as to why recognized frameworks should not be used in coding all web applications." You might be right, Mike. Again, I'm not saying that frameworks are bad, nor unnecessary. Just that frameworked code isn't the only place that you can find good OO code.
# Posted By yacoubean | 6/11/06 4:07 PM
> You will see this post as a 'troll' because you are
> 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!"
# Posted By Joe Rinehart | 6/13/06 10:52 AM
Hi, my name is Scott, and I use frameworks.

{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.
# Posted By Scott Stroz | 6/13/06 11:51 AM
While I happen to be in the "Frameworks are Good" camp, I have observed that some CF developers that are not firmly in the frameworks camp perceive the message from the frameworks guys that they are inferior to their frameworks brethren. While that is definitely not the message, I do think that is how it gets heard by some people.
# Posted By brian | 6/13/06 1:00 PM
Joe,

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. :)
# Posted By yacoubean | 6/13/06 1:10 PM
Brian,

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.
# Posted By yacoubean | 6/13/06 1:12 PM
Oh boy... gotta love these threads!

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.
# Posted By Sean Corfield | 6/13/06 1:28 PM
I have always had the state of mind to never use frameworks when creating applications. The reason, SPEED. Pick a framework, any framework, I don't which one. I will bet my life that there isn't a framework out there that doesn't decrease (in terms of speed) the loading of the page by at least 4 fold. I've tried several frameworks (I won't say which ones to prevent a flamewar) and all of them have failed in this department. Using them, I saw my page load times jump from 31ms to over 400ms! Doesn't any load test these things before they release them? And if you do, what makes you think that a 400ms load time is acceptable?!?!

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.
# Posted By Tony Petruzzi | 6/13/06 2:39 PM
Tony, sounds like you were running the frameworks in non-production modes. Most frameworks add very little overhead when running in production mode.
# Posted By Sean Corfield | 6/13/06 3:14 PM
It also sounds like Tony's using ColdFusion debugging to judge load times, which is pretty much a worthless exercise the moment you involve CFCs.

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.
# Posted By Joe Rinehart | 6/13/06 6:17 PM
Sean,

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?
# Posted By yacoubean | 6/13/06 6:50 PM
I would have to disagree that Matt and Peter were implying that you can't get that maintainability without a framework.

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.
# Posted By Matt Williams | 6/14/06 8:57 AM
Wow this post has gone nuts. Somehow it feels as if you are taking the comments of some well known proponents of frameworks very personally, and reading alot into them that isn't there. I agree with Matt (who makes the same point Joe did a while back): you make a logical fallacy when you conclude that by saying a framework can improve maintanability, that you are thereby saying that not using one will decrease maintainability. It's like when they say "actual results may vary".

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.
# Posted By Brian Rinaldi | 6/14/06 10:58 AM
I have to say that Tony Petruzzi's coment has to be one of the most comical things I've read all year. It's not that he's so incredibly misinformed about frameworks, it's that he's so confident that he "knows better", like the thousands of CF developers who use frameworks have their heads in the sand and wait 500ms for every page to load thinking in their mind ("oh it's because I used 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.
# Posted By Dave Ross | 6/14/06 11:40 AM
I'm going to say this one more time, I'm not putting words into people's mouths. I'm just repeating what I've heard. There /were/ people that have directly said that non-frameworked code is not easily maintainable. Now you guys can get nitpicky about the meaning behind a couple of examples I've posted, and we'll just have to agree to disagree.

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).
# Posted By yacoubean | 6/14/06 12:17 PM
I've been using Fusebox since the beginning. The actual beginning that is, having written the very first Fusebox website almost 10 years ago. I think frameworks are great, i think they have their place in web apps. I also think in the last few years they've gotten so complex they've taken a step backwards. I've tried pretty much every CF framework out there, i still prefer the MVC concepts of Fusebox 4. It's inline with how i picture software in my head. But i'm slowly realizing those MVC concepts can all be done directly with CFCs, without 'core' files and without learning another XML language. Lately that's how i've been building my own apps. But it's hard to argue this new style is more or less maintainable that a fusebox 4 application. It's probably a wash.

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.
# Posted By Steve Nelson | 6/14/06 5:34 PM
I have to agree with Steve Nelsons comment.

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.
# Posted By Wayne Putterill | 6/15/06 3:10 AM
Wayne, tell me if this is too complex. I've had tunnel vision so maybe it is still too complex...

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.
# Posted By Steve Nelson | 6/15/06 10:24 AM
Steve,

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.
# Posted By yacoubean | 6/15/06 1:25 PM
Yeah the controller concept isn't obvious, but it is very powerful. Here are a couple examples. Sure there are lots of different solutions to these problems, but try to see where i'm going with this. Compare these two functions:

<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.
# Posted By Steve Nelson | 6/15/06 2:30 PM
yacoubean - another question to consider is why bother cfincluding a file inside of a cffunction? In a loose framework like this it's totally up to you. Personally I ALWAYS cfinclude files in cffunctions, I think it gets back to my 3 criteria above. The second one about small file sizes is critical to code maintenance. cfincluding files dramatically reduces the size of CFCs, making them easier to read. Consider trying to put multiple UIs in a CFC without cfincluding. It's ludicrous. Your CFCs might be 1000s of lines long. But cfinclude the templates inside the cffunctions and suddenly it's simple. The same is true for Model CFCs.
# Posted By Steve Nelson | 6/15/06 2:45 PM
Steve,

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. :)
# Posted By yacoubean | 6/15/06 6:02 PM
I read the wikipedia article on MVC, and I can see how the controller could help. However, I also saw this line, "The most important separation is between presentation and domain (model); the View/Controller split is less so." So it appears that other people are thinking along the same lines I am (that the controller isn't super important).
# Posted By yacoubean | 6/15/06 6:29 PM
Steve, at a quick glance it looks like there might be something usable (and more importantly understandable) there.

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.
# Posted By Wayne Putterill | 6/16/06 1:50 AM
Wayne, that's sort of true, but not exactly. Frameworks progressed faster than the language itself progressed. For example, the very first version of Fusebox almost 10 years ago started with cfif/cfelse statements for the "fuseactions" (a CFFUNCTION above). Then ColdFusion added the cfswitch tag, that made things easier to read and considerably faster. Then ColdFusion added the custom tag allowing for the original cf_bodycontent tag. This allowed for nested layouts (this is done with the returnvariable above). Arguably the most important UI advancement ever as far as frameworks are concerned. Then ColdFusion added XML support that opened a can of worms in all the frameworks. The XML approach has its pluses and minuses. CFCs are the latest tool available in CF engineering.

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.
# Posted By Steve Nelson | 6/16/06 8:57 AM
Yacoubean- I'm not sure its wise to pinpoint a single important idea and focus solely on that. But saying that I think you can get away with focusing on a small handful of things. Of course everyones preference is probably different. I'll have to think about mine. MVC is definitely at the top of the list for me, well after indenting code and small file sizes.
# Posted By Steve Nelson | 6/16/06 9:02 AM
Steve,

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.
# Posted By yacoubean | 6/16/06 10:37 PM
Somewhere in your code, whether it is at the top of each page, or in its own seperate file, you must have logic that determines which Model and View ro run/display. That logic is your controller.

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.
# Posted By Scott Stroz | 6/17/06 7:38 AM
This is a great thread in my opinion, thanks. I posted one comment before but I don't think it expressed my point of view well; from experience I gained traveling the globe troubleshooting CF applications. If I encounter a Frameworked App which has not deviated from the Framework then the time it takes me to assimilate the App is much quicker, benefiting the client.

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.
# Posted By Mike Brunt | 6/17/06 8:38 AM
Steve,

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).
# Posted By Scott Stroz | 6/17/06 9:03 AM
sorry...I am asking the above question to see if there are performance advantages of using <cfmodule>
# Posted By Scott Stroz | 6/17/06 9:04 AM
Mike,

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.
# Posted By yacoubean | 6/17/06 10:08 AM
Steve, I love your explanation of a simple framework. It is very clear and concise. It got me thinking that is how a great CF framework should be. It should start as CF itself does: simplify, simplify, simplify and be just as clear and concise. Most of that is already in CF using cfc's and adding some folders such as model, view, controller, etc.. I would love to see a tutorial/documentation resource out there that goes into best practices of maintainable code using cfc's and organisation without frameworks (which as Sam said are methodologies with functions automated by code - think DreamWeaver wizards) that get most of the benefits of a framework without the complexity and steep learning curve. Do you know of a resource out there like that? The place you were heading with your explanation of a simple framework could be expanded to use what CF has in place with just a methodology of maintainability.

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.
# Posted By P.C. Wroble | 6/24/06 11:39 AM
P.C.,

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.
# Posted By yacoubean | 6/24/06 1:05 PM
Jacob,

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
# Posted By Jared Rypka-Hauer | 6/30/06 8:15 AM
I just get tired of the flaming if you don't happen to follow frameworks or OO.

It gets pretty offensive sometimes.
# Posted By Craig M. Rosenblum | 6/30/06 11:55 AM
It seems that we have already made up our minds on this topic.

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.
# Posted By Brian | 7/9/06 11:37 AM
A+
# Posted By Kanye West | 2/18/08 12:26 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner