Introduction to Coldfusion Components

Introduction

Coldfusion Components also known as CFC’s. A lot of people I know who program Coldfusion and not use CFC’s have as excuse; it’s too hard to learn! It’s too hard to learn?? No way!!

It’s very easy to learn. It’s just an other way of thinking than you’re used to. You must see CFC’s as building blocks. By constructing “building blocks” you’re code is much cleaner and far more reusable, thus quicker to build your application. Most (if not every) Coldfusion developer knows UDF’s (User Defined Functions) and Custom Tags. CFC’s are almost the same as Custom Tags, but have some differences:

  • Custom Tags have a single entry point; CFC’s can have multiple entry points. This makes it possible to create a single component that does many related actions. (To do that with custom tags you would need multiple tags or cumbersome switch processing.)
  • Custom Tags have no formalized parameters passing and validation mechanism; CFC’s do. In other words unlike custom tags, CFC’s can validate passed data, enforce data types, check for required parameters, and optionally assign default values.
  • Custom Tags cannot persist; CFC’s can. Custom Tags are blocks of code that are executed as is, while CFC’s are objects and can be treated as such.
  • Custom Tags are designed to contain code; CFC’s are designed to contain both code and data.
  • Custom Tags are accessible only by Coldfusion and only locally; CFC’s can be accessed as web services, opening up a whole new world of reuse possibilities.

To sum it up, CFC’s and Custom Tags are quite different. Although their functionality does overlap a little, they really do not solve the same problems at all. So to learn the basics of CFC’s while head right on it and start with some sample “spaghetti code” and transform it to a structured and reusable way; a CFC. Please note that this article only covers the basics of CFC’s and does not handle any advanced topics.

$2.79
- OR -

Overview

CFC benefits

There are a lot of benefits by using CFC’s. First of all you’ll separate the “business logic” (such as database queries, sending out emails and etc) from the “presentation layer” (displaying a user list or a product catalogue). This will make the complete application much easier to maintain and bring down development time. Also the benefit of code reuse is very big. By reusing existing code it’s much easier to maintain your application, also the development time is brought down by reusing code. 

Michael van Leest

Michael van LeestI'm a Coldfusion an Flex developer

Certified Macromedia Coldfusion MX 7 developer
Certified Macromedia Coldfusion MX developer
Certified BrainBench Coldfusion MX developer
Certified Macromedia Dreamweaver 8 developer
Certified Macromedia Dreamweaver MX 2004 developer

If you have any questions or problems with Coldfusion/Dreamweaver/Flex... Mail me and I'll see what I can do for you.

Take a look at my blog:
http://www.wantonline.com/blog
And take a look at the Coldfusion Flex Community:
http://www.cfflex.com

See All Postings From Michael van Leest >>

Reviews

Need more information

July 22, 2005 by sunil kumar vasu

I didn't find this article much useful it just a basic stuff which you could find anywhere in the internet. I was looking for some sample code at using at the advance level.

Cheers,

S~ 

You must me logged in to write a review.