Coldfusion Components also known as CFC's. A lot of people program Coldfusion and not use CFC's have; 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.



More Information visit ColdFusion Development.


0 comments