Presentation is loading. Please wait.

Presentation is loading. Please wait.

CFUNITED – The premier ColdFusion conference ColdFusion Components Ajay Sathuluri Based on presentation.

Similar presentations


Presentation on theme: "CFUNITED – The premier ColdFusion conference ColdFusion Components Ajay Sathuluri Based on presentation."— Presentation transcript:

1 CFUNITED – The premier ColdFusion conference www.cfunited.com ColdFusion Components Ajay Sathuluri ajay@teratech.com http://www.teratech.com Based on presentation at the CFUNITED 06 Conference by Ray Camden

2 June 28 th – July 1 st 2006 About Me  Certified ColdFusion MX Developer  Microsoft Certified Solution Developer  ColdFusion Developer  7+ years with ColdFusion  Also work with SQL, JavaScript, HTML, Access, VB, Oracle  On site and custom development  Fusebox and Process Methodology

3 June 28 th – July 1 st 2006 Why.Net developers envy us…

4 June 28 th – July 1 st 2006 ColdFusion Components  What are they? A component can be thought of a combination of data (properties) and functions (methods) A simple mechanism for building web services It is not object orientation!

5 June 28 th – July 1 st 2006 Basics  Must be named with cfc extension  Collection of user-defined functions wrapped with tags  In general, basic CFML  Very simple!

6 June 28 th – July 1 st 2006 This simple…

7 June 28 th – July 1 st 2006 <cfcomponent>  displayName  hint  output  extends  More arguments for web services

8 June 28 th – July 1 st 2006 <cffunction>  name  returnType  roles  access  output  displayName, hint, description

9 June 28 th – July 1 st 2006 ColdFusion Components  Example

10 June 28 th – July 1 st 2006 Using Components   createObject()  Direct invocation via Form, URL, Flash Remoting  Web Services

11 June 28 th – July 1 st 2006 & &  component (name or variable)  method  returnVariable  argumentCollection  cfinvokeargument: name/value/omit

12 June 28 th – July 1 st 2006 & &  Example

13 June 28 th – July 1 st 2006 createObject() & cfobject  Allows you to create an “instance” of the CFC. 

14 June 28 th – July 1 st 2006 createObject() & cfobject  Example

15 June 28 th – July 1 st 2006 Direct Invocation  URL  Form

16 June 28 th – July 1 st 2006 CFCs with Data  Two Scopes (This/Variables) Variables is an internal scope. This is an external scope.  Can persist between calls (if the CFC persists)

17 June 28 th – July 1 st 2006 CFCs with Data  Example

18 June 28 th – July 1 st 2006 This versus Variables  Because the This scope is available outside the component, many developers shy away from it since it can lead to a lack of encapsulation.  Just (don’t) do it! Remember the 99% rule!

19 June 28 th – July 1 st 2006 CFC Initializers  All code outside of cffunction tags is run automatically  Use an init() method

20 June 28 th – July 1 st 2006 CFC Initializers  Example

21 June 28 th – July 1 st 2006 CFC Security  Access Defines how the methods can be called. Roles:  Private  Public  Remote  Package  Roles Defines who can call the methods.

22 June 28 th – July 1 st 2006 CFC Security  Example

23 June 28 th – July 1 st 2006 Metadata  getMetaData()  Returns a whole heck of a lot of stuff!  Used by the descriptor

24 June 28 th – July 1 st 2006 Metadata  Example

25 June 28 th – July 1 st 2006 “Best” Practices

26 June 28 th – July 1 st 2006 Var Scope  Or die the death of a thousand cuts…  Any variable created inside a method must be properly scoped.  Note new “result” attributes in CFMX7

27 June 28 th – July 1 st 2006 Don’t use “outsiders”  CFCs should never* use: Application Session Client URL, Form, CGI, Server, Etc  But the opposite is not true… * Except when I say it’s ok.

28 June 28 th – July 1 st 2006 Strip that output…  output=“false”  Applies to both cfcomponent and cffunction

29 June 28 th – July 1 st 2006 Strip that output…  Example

30 June 28 th – July 1 st 2006 Got cache?  Creating a CFC is expensive.  Only make em when ya need em!  Data inside can be cached as well.

31 June 28 th – July 1 st 2006 Have Fun


Download ppt "CFUNITED – The premier ColdFusion conference ColdFusion Components Ajay Sathuluri Based on presentation."

Similar presentations


Ads by Google