Our first CFC
We start by creating a file that ends with .cfc
when creating CFCs. Non-CFC files that you have been creating up to this point, and will also continue to create, end with .cfm
.
Each CFC is wrapped by a set of tags and has one or more functions, which are also referred to as methods. We will be creating an object class. There are different types of objects, and a CFC is the type we normally use in ColdFusion. Now, let us look at some empty code, so you can get an idea of what one might look like:
<cfcomponent> <cffunction> </cffunction> </cfcomponent>>
Certainly, we cannot do much with this segment of code. This is just for us to get a first glimpse of CFC code. Here, we get an idea of what it is and start our journey of discovery. You see there is a <cfcomponent>
tag that surrounds the whole CFC. You can add additional attributes, but for now we are going to keep it as simple as possible and try to learn how to write CFCs without getting bogged...