Download presentation
Presentation is loading. Please wait.
Published byKimberly Gray Modified over 9 years ago
1
CFC Best Practices, Tips, and Tricks Raymond Camden jedimaster@mindseye.com
2
Agenda Basic (but real!) Examples Best Practices (Suggestions) Tips and Tricks Resources
3
Examples www.cflib.org CFCs serve as DB abstraction ResourceBundle CFC Localization Utility SimpleCMS Simple CMS based on CFCs
4
Best Practices Control white space generated by CFC
5
Best Practices Supply Optional Attributes <cffunction name="test" returnType="string" access="public" output="false" hint="This function does blah using Foo's logic.">
6
Best Practices Use the VAR scope!.....
7
Understand Data Scopes Variables This Arguments Function Local
8
Cache CFC Instances CFC creation can be slow. Use createObject/cfobject to create an instance. (typically) works with new instances.
9
Pseudo-Constructor Any code not inside. Useful to initialize variables. BlueDragon has
10
Dealing with Application Variables Application.cfm and when it's run: Flash Remoting/WS calls Same folder Don't rely on it! Application CFC
11
Inheritance/Super Use for Is-A, not Has-A In other words, inheritance is used when a CFC defines as "is a" relationship with it's parent. It should not be used for simple code re-use. Super allows for a child method to extend a parent method.
12
Pass by Ref/by Value Values passed to CFC methods follow the same rules as values passed to UDFs. The following are passed by reference: Structures Queries Other "comlpex" objects (including CFCs)
13
Resources www.cfczone.org cfcdev mailing list Top Ten Tips article by Rob Brooks-Bilson http://www.oreillynet.com/pub/a/javascript/2003/09 /24/coldfusion_tips.html?page=1 CFC Best Practices by Nathan Dintenfass http://www.dintenfass.com/cfcbestpractices/
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.