Presentation is loading. Please wait.

Presentation is loading. Please wait.

CFCs in Practice Raymond Camden Senior Developer, Mindseye Technologies.

Similar presentations


Presentation on theme: "CFCs in Practice Raymond Camden Senior Developer, Mindseye Technologies."— Presentation transcript:

1 CFCs in Practice Raymond Camden (jedimaster@mindseye.com) Senior Developer, Mindseye Technologies

2 Agenda  Quick Intro to ColdFusion Components (CFCs)  CFC Coding Details and Tips  CFC “Issues”  CFC Examples  Q & A

3 3 “Life Through a Browser” CFCs in a Nutshell  A new way to encapsulate code.  Collection of methods with built in security  Quick and Easy Web Services  Pseudo-Object Oriented (No, it’s not really OO)  New tags:,,,

4 4 “Life Through a Browser” CFC Example

5 5 “Life Through a Browser” CFC Example (2) #greeting# #greeter.sayHello()#

6 6 “Life Through a Browser” CFC Tips: Constructors  CFCs do not have a formal constructor…  However – any code not inside a method is run when the CFC is instantiated (created or called remotely).  Generates white space! Use output=false in (also in )

7 7 “Life Through a Browser” CFC Tips: Let’s Talk about Data  This  Accessible to caller code  Shows up in dump, but not getMetaData()  Unnamed “private” scope  Not accessible to caller code  Accessible to children  Not like Variables, can’t be dumped. (Fixed in RedSky)  Method arguments  Method temporary variables (var scope)

8 8 “Life Through a Browser” CFC Methods  Default access is public – change to private  Specify all attributes, even optional ones:  access (important for security!)  returnType (important for validation!)  output (controls white space!)  hint  roles

9 9 “Life Through a Browser” CFC Methods (2)  returnType should be one of: anynumeric arrayquery binarystring booleanstruct dateuuid guidvariableName  Or must be the name of a CFC type  Watch out for structure instead of struct, number instead of numeric, etc.

10 10 “Life Through a Browser” CFC Methods (3)  Output versus Return  Outputting from the method will not work for Flash Remoting  Use the var scope  This is intentional: Use the var scope  Applies to UDFs as well!

11 11 “Life Through a Browser” - What does it really do?  It does NOT create variables.  It does NOT validate variables.  It does create entries in the meta data.  It helps define the WSDL returned by a web service

12 12 “Life Through a Browser” CFC “Issues”  inside a method will not have access to Arguments  and CFCs  ArgumentCollection and  Cached CFCs lose access to output, other scopes  You can’t duplicate (correctly) or serialize (correctly) a CFC  Undefined arguments show up in arguments struct

13 13 “Life Through a Browser” Web Services Gotchas…  No optional arguments allowed for methods  AXIS limitation  Caching of Arguments  Fixed by using CF Admin to refresh the WS

14 14 “Life Through a Browser” CFC Examples  Session Tracker  Unit Tester (from DRK3)  Nathan Dintenfass’ Descriptor

15 15 “Life Through a Browser” Questions and Resources  www.cfczone.org  cfcdev mailing list  Macromedia DevNet Articles  http://www.macromedia.com/devnet/mx/coldfusion/cfcs.html  CFDJ Articles


Download ppt "CFCs in Practice Raymond Camden Senior Developer, Mindseye Technologies."

Similar presentations


Ads by Google