Welcome!

You will be redirected in 30 seconds or close now.

ColdFusion Authors: Yakov Fain, Jeremy Geelan, Maureen O'Gara, Nancy Y. Nee, Tad Anderson

Related Topics: ColdFusion

ColdFusion: Article

Frameworks, Frameworks, Frameworks

Why you should use a framework - Part 1

Your boss tells you that he wants you to build a ColdFusion application based on his requirements, which will take you about a month to complete. You are now faced with two options, you can either start coding your application in spaghetti code fashion, or you can explore the many frameworks ColdFusion offers and choose one of them.

Writing spaghetti code for many is an easy solution, by approaching the application development with a top-to-bottom declaration of code. Using the spaghetti code method will seem logical at first but you'll soon realize that there's so much code you'll be lost debugging the program for months. A framework for ColdFusion is just like books with a table of contents at the front and an index at the back. Because this pattern is always used, anyone who uses the book knows how to access information they need from that book, so frameworks have the same pattern for universal use. Using a framework(s) is the way to go because it will cut your development time, give you better productivity as well as increased code reusability, and help you organize your code and make it easier for future enhancements.

There is nevertheless a lot of contradiction as to whether frameworks are needed. The main argument on the flip side of the coin is that the learning curve for any frameworks is steep. Well, there is quite a challenge, but if you're going to build something sophisticated in the first place then this learning curve is no challenge to you at all. Another reason why this learning curve is worth the turn is because if you don't use a framework in the long run the code might get so unmanageable that you'll have no choice but to start from scratch, wasting valuable time and in most cases money. Another well-known argument is that frameworks are for beginners who want to use the RAD methodology of development. This, however, isn't true, because it's a well-known fact that all the big software development firms use frameworks when developing applications. There are many famous frameworks such as the .NET framework for the Win32 and Win64 platforms, and in terms of Web application frameworks there are numerous frameworks that are used by major Web sites such frameworks Coldbox, Fusebox, and Mach II. All in all, yes, there's quite a learning curve, but accepting the challenge will make your life much easier and keep your code managed and clean.

All developers know that time is always against them. A deadline is always looming over a developer's head and he or she is always in a rush to complete the application's lifecycle. It's not that the developer can't write code quickly, it's that once the code is written, debugging takes a much more time. By using an application framework, you'll have enough time to develop an entire operating system. An application framework is a predefined structure that will help you organize your application by using various object-oriented programming methodologies. Another reason why your development time will be reduced is that in almost every framework there's a set of predefined "solutions" that you can use to unravel a lot of the problems you might encounter during development. A good example of a framework that has predefined solutions is the Fusebox framework in which you simply tell the circuit.xml file when and what you want to load and it'll do the processing and code generation without any errors.

Another great motive for using an application framework is that you won't have to do repetitive tasks over and over again. For example, if you wanted every page on your site to check if the user is logged in, and you have well over a thousand pages of information the non-framework way of doing it will be to open each page and add a isDefined(Session.user) function to do the validation. However. what if you change the session variable to something other than user, you'll have to open thousands of pages again to change that variable. Using this approach will cost a lot of time and valuable resources. On the other hand, if you used a framework, you could have defined that on each page-request executing the function isDefined(Session.user) and later on if you were to change the session variable, you could easily change just one line of code in your application framework and it would do the job for you.

Better productivity is what every software developer wants and by using an application framework you'll get just that. In general, most application frameworks use object-oriented programming methodologies, which give you a lot of code reusability that in turn give you better productivity. For instance, if you were to create a class or cfc component (in this case) of all the items your authentication system does in your application then by using a framework like MACH II or even designing your own proprietary framework you can call the functions in those classes numerous times without having to write the code that many times.

The basic ColdFusion application framework that many like to call the Application.cfc framework is an example of how a framework can lead to better productivity. There are several solutions built into the framework that help you reuse your code. One useful method is the OnError, which is called whenever there's an error on your cfm page. In between this method you can declare some code such as <cfinclude template='error.cfm'/>, which tells the user to contact you in case of an error and every time an error occurs your code will be executed. This is a good example of code reusability because you don't have to go through all your pages and error check; instead by using that method the framework will do it for you. Also, some developers who are looking to use their time well can rest assured that all of these frameworks are simple to install, simple to use, and simple to deploy. To get any of these frameworks running, all you have to do is create a ColdFusion mapping to the core framework files and then use the framework skeleton application to develop on it. In sum, you'll have a much more productive environment and achieve a higher rate of code reusability.

Another reason to consider using a framework is that over time your code will grow, with all the patches and maintenance you make to it, and if you're using the spaghetti code method your code will look like it's been encrypted using AES. So rather than letting that unfortunate event occur, using a framework will help organize and maintain your code. An example would be using a framework such as Fusebox 5.1 and its MVC architecture to organize your code. Using an MVC architecture helps separate your code logic tier from your presentation tier and by doing this if you ever have to make modifications you can rest assured that it will have no visual impact on your presentation tier and vice versa. If you were to compare spaghetti code style to MVC-type architecture, you'll clearly see why life is easier on the MVC side. A framework will also increase code readability by organizing the code in a human-readable logical way, an example would be the Coldbox framework, which has a framework dashboard used to organize all your configurations of the application, so instead of digging deep into the code, you can easily configure your framework and application with a simple dashboard. Another great framework that you can use for a simple MVC-type architecture is MACH II in which you'll be able to develop applications faster than MACH II. What a fun framework. Generally speaking, a framework is a really good way to keeping all your code organized and will help you a lot when it comes to updating and adding new features in your code over the course of the application lifecycle.

All in all, using a framework can help increase code reliability by minimizing errors, increase productivity, and maintain your code through out the application lifecycle. As you can clearly see, these give you a significant advantage over the old spaghetti code method and learning how to use a framework can and will give you a good asset in your skill set. Many large corporations are looking for people skilled in many of the top application frameworks such as Fusebox and MACH II. Overall, after using a framework you'll wonder how you ever developed applications without it..

More Stories By Faisal Abid

Faisal Abid is a third-year student at West Hill CI and loves Flex, ColdFusion, and rich Internet applications. He is also the founder and owner of G-uniX Technologies (www.G-uniX.com), an RIA software development consultancy based in Toronto that specializes in Flex 2 and ColdFusion applications. He has a blog at blog.G-uniX.com that he updates bi-weekly with G-uniX news, Flex tutorials, ColdFusion tutorials, and Spry tutorials.

Comments (1)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
Moroccanoil®, the global leader in oil-infused beauty, is thrilled to announce the NEW Moroccanoil Color Depositing Masks, a collection of dual-benefit hair masks that deposit pure pigments while providing the treatment benefits of a deep conditioning mask. The collection consists of seven curated shades for commitment-free, beautifully-colored hair that looks and feels healthy.
The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
We all love the many benefits of natural plant oils, used as a deap treatment before shampooing, at home or at the beach, but is there an all-in-one solution for everyday intensive nutrition and modern styling?I am passionate about the benefits of natural extracts with tried-and-tested results, which I have used to develop my own brand (lemon for its acid ph, wheat germ for its fortifying action…). I wanted a product which combined caring and styling effects, and which could be used after shampo...
The platform combines the strengths of Singtel's extensive, intelligent network capabilities with Microsoft's cloud expertise to create a unique solution that sets new standards for IoT applications," said Mr Diomedes Kastanis, Head of IoT at Singtel. "Our solution provides speed, transparency and flexibility, paving the way for a more pervasive use of IoT to accelerate enterprises' digitalisation efforts. AI-powered intelligent connectivity over Microsoft Azure will be the fastest connected pat...
There are many examples of disruption in consumer space – Uber disrupting the cab industry, Airbnb disrupting the hospitality industry and so on; but have you wondered who is disrupting support and operations? AISERA helps make businesses and customers successful by offering consumer-like user experience for support and operations. We have built the world’s first AI-driven IT / HR / Cloud / Customer Support and Operations solution.
Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
Druva is the global leader in Cloud Data Protection and Management, delivering the industry's first data management-as-a-service solution that aggregates data from endpoints, servers and cloud applications and leverages the public cloud to offer a single pane of glass to enable data protection, governance and intelligence-dramatically increasing the availability and visibility of business critical information, while reducing the risk, cost and complexity of managing and protecting it. Druva's...
BMC has unmatched experience in IT management, supporting 92 of the Forbes Global 100, and earning recognition as an ITSM Gartner Magic Quadrant Leader for five years running. Our solutions offer speed, agility, and efficiency to tackle business challenges in the areas of service management, automation, operations, and the mainframe.