When defining CFCs, it is good programming practice to organize related methods in one CFC. For example, you could put all methods that perform operations related to a user, such as addUser, editUser, and storeUserPreferences, in one CFC. You can group related mathematical functions into one CFC. A CFC can also contain all the methods and properties necessary for a shopping cart. The following CFC contains two cffunction tags that define two component methods, getEmp and getDept. When invoked, the component methods query the ExampleApps database. The cfreturn tag returns the query results to the client, or page, where the method was invoked.
<cfcomponent> <cffunction name="getEmp"> <cfset var empQuery=""> <cfquery name="empQuery" datasource="cfdocexamples" dbtype="ODBC"> SELECT FIRSTNAME, LASTNAME, EMAIL FROM tblEmployees </cfquery> <cfreturn empQuery> </cffunction> <cffunction name="getDept"> <cfset var deptQuery=""> <cfquery name="deptQuery" datasource="cfdocexamples" dbtype="ODBC"> SELECT * FROM tblDepartments </cfquery> <cfreturn deptQuery> </cffunction> </cfcomponent>