+ All Categories
Home > Documents > CFUNITED – The premier ColdFusion conference ColdFusion Components Ajay Sathuluri...

CFUNITED – The premier ColdFusion conference ColdFusion Components Ajay Sathuluri...

Date post: 18-Jan-2016
Category:
Upload: ella-sherman
View: 222 times
Download: 3 times
Share this document with a friend
Popular Tags:
31
CFUNITED – The premier ColdFusion conference www.cfunited.com ColdFusion ColdFusion Components Components Ajay Sathuluri [email protected] http://www.teratech.com Based on presentation at the CFUNITED 06 Conference by Ray Camden
Transcript
Page 1: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

CFUNITED – The premier ColdFusion conference www.cfunited.com

ColdFusion ColdFusion ComponentsComponents

Ajay [email protected]

http://www.teratech.com

Based on presentation at the CFUNITED 06 Conference by Ray Camden

Page 2: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

About MeAbout 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

Page 3: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

Why .Net developers envy us…Why .Net developers envy us…

Page 4: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

ColdFusion ComponentsColdFusion 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!

Page 5: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

BasicsBasics

Must be named with cfc extension Collection of user-defined functions

wrapped with <cfcomponent> tags In general, basic CFML Very simple!

Page 6: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

This simple…This simple…

Page 7: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

<cfcomponent><cfcomponent>

displayName hint output extends More arguments for web services

Page 8: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

<cffunction><cffunction>

name returnType roles access output displayName, hint, description

Page 9: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

ColdFusion ComponentsColdFusion Components

Example

Page 10: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

Using ComponentsUsing Components

<cfinvoke> createObject() Direct invocation via Form, URL, Flash

Remoting Web Services

Page 11: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

<cfinvoke> & <cfinvokeargument><cfinvoke> & <cfinvokeargument>

component (name or variable) method returnVariable argumentCollection cfinvokeargument: name/value/omit

Page 12: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

<cfinvoke> & <cfinvokeargument><cfinvoke> & <cfinvokeargument>

Example

Page 13: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

createObject() & cfobjectcreateObject() & cfobject

Allows you to create an “instance” of the CFC.

<cfset theCFC = createObject(“component”, “myCFC”)>

Page 14: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

createObject() & cfobjectcreateObject() & cfobject

Example

Page 15: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

Direct InvocationDirect Invocation

URL Form

Page 16: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

CFCs with DataCFCs with Data

Two Scopes (This/Variables)Variables is an internal scope.This is an external scope.

Can persist between calls (if the CFC persists)

Page 17: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

CFCs with DataCFCs with Data

Example

Page 18: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

This versus VariablesThis 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!

Page 19: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

CFC InitializersCFC Initializers

All code outside of cffunction tags is run automatically

Use an init() method

Page 20: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

CFC InitializersCFC Initializers

Example

Page 21: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

CFC SecurityCFC Security

AccessDefines how the methods can be called.Roles:

Private Public Remote Package

RolesDefines who can call the methods.

Page 22: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

CFC SecurityCFC Security

Example

Page 23: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

MetadataMetadata

getMetaData() Returns a whole heck of a lot of stuff! Used by the descriptor

Page 24: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

MetadataMetadata

Example

Page 25: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

““Best” PracticesBest” Practices

Page 26: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

Var ScopeVar 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

Page 27: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

Don’t use “outsiders”Don’t use “outsiders”

CFCs should never* use:ApplicationSessionClientURL, Form, CGI, Server, Etc

But the opposite is not true…

* Except when I say it’s ok.

Page 28: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

Strip that output…Strip that output…

output=“false” Applies to both cfcomponent and

cffunction

Page 29: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

Strip that output…Strip that output…

Example

Page 30: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

Got cache?Got cache?

Creating a CFC is expensive. Only make em when ya need em! Data inside can be cached as well.

Page 31: CFUNITED – The premier ColdFusion conference  ColdFusion Components Ajay Sathuluri ajay@teratech.com  Based on presentation.

June 28th – July 1st 2006

Have FunHave Fun


Recommended