Skip to main content
December 6, 2011
Answered

New to ColdFusion - Question regarding best practice

  • December 6, 2011
  • 3 replies
  • 1371 views

Hello there.

I have been programming in Java/C#/PHP for the past two years or so, and as of late have really taken a liking to ColdFusion.

The question that I have is around the actual seperation of code and if there are any best practices that are preached using this language. While I was learning Java, I was taught that it's best to have several layers in your code; example: Front end (JSPs or ASP) -> Business Objects -> Daos -> Database. All of the code that I have written using these three languages have followed this simple structure, for the most part.

As I dive deeper into ColdFusion, most of the examples that I have seen from vetrans of this language don't really incorporate much seperation. And I'm not referring to the simple "here's what this function does" type of examples online where most of the code is written in one file. I've been able to see projects that have been created with this language.

I work with a couple developers who have been writing in ColdFusion for a few years and posed this question to them as well. Their response was something to the affect of, "I'm not sure if there are any best practices for this, but it doesn't really seem like there's much of an issue making calls like this".

I have searched online for any type of best practices or discussions around this and haven't seen much of anything.

I do still consider myself somewhat of a noobling when it comes to programming, but matters of best practice are important to me for any language that I learn more about.

Thanks for the help.

    This topic has been closed for replies.
    Correct answer Joshua_Cyr

    You may want to take a look at a number of great frameworks available for

    ColdFusion.

    FW/1, Model Glue, CFWheels, ColdBox, or Mach II . These do a great job of

    giving you a path for code separation, best practices, etc.

    http://www.carehart.org/cf411/#cffw

    3 replies

    Participating Frequently
    December 7, 2011

    Frameworks for Web Applications can require alot of overhead, more than you might normally need programming ColdFusion, I have worked with Frameworks, including Fusebox, what I discovered is when handing a project over to a different developer, it took them over a month before they were able to fully understand the Fusebox framework and then program it comfortably. I decided to not use Fusebox on other projects for this reason.

    For maintainability sometimes its better to not use a framework, while there are a number of ColdFusion developers, those that know the Fusebox framework are in the minority. When using a framework, you always have to consider the amount of time to learn it and succesfuly implement it. Alot of it depends on how much of your code you want to reuse. One thing you have to consider, is if you need to make a change to the web application, how many files will you have to modify? Sometimes its more files with a framework than if you just write code without a framework.

    While working on a website for Electronic Component sourcing, I encountered this dynamic several times.

    Michael G. Workman

    mworkman@usbid.com

    http://www.usbid.com

    http://ic.locate-ic.com

    Inspiring
    December 6, 2011

    For any newcomer to an established workplace, I think the best practice is adjust to what is already being done.  Learning what is being done and why will put you in a better position to make things better.  I suspect you are already doing that.

    Regarding the programming layers you describe, you can do that in CF if the situation is appropriate.  In my case where most of my work involves running a query or two, possibly muckking about with the data, and then displaying the results, I have yet to see that approach as a best practice.

    Owainnorth
    Inspiring
    December 7, 2011

    As Dan says it's more important to work with whatever's there, but yes certainly bespoke, large systems I've written I've gone into DAOs, Gateways and the such. Personally I don't like frameworks, I think you can spend as much time configuring and debugging them as it would've taken you to just write it yourself if you know what you want.

    There are no hard and fast rules, and certainly for small sites there's often nothing wrong with just stuffing a CFQuery at the top of a page. However for larger sites, I tend to end up with:

    Class

    + DAO

    + Gateway

    And that tends to allow me enough flexibility to completely remove and replace a component should I need to.

    O.

    Joshua_CyrCorrect answer
    Participating Frequently
    December 6, 2011

    You may want to take a look at a number of great frameworks available for

    ColdFusion.

    FW/1, Model Glue, CFWheels, ColdBox, or Mach II . These do a great job of

    giving you a path for code separation, best practices, etc.

    http://www.carehart.org/cf411/#cffw

    December 6, 2011

    Ok great! Thank you.