Title: N-tier ColdFusion Development with CFC
1N-tier ColdFusion Development with CFCs
- Neil Ross, MCP
- neil_at_codesweeper.com
- www.codesweeper.com
- www.insidecoldfusionmx.com
2Introduction
- Neil Ross
- Co-Author of Inside ColdFusion MX
- Certified ColdFusion Developer
- Certified ColdFusion Instructor
- Presenter at DevCon 2000 in DC
- Founder and Manager of Central Pennsylvania
ColdFusion User Group - Former member of Allaire Consulting Services
3Overview
- Understanding the Main Concepts
- N-tier Applications
- CFCs
- N-tier Architecture
- Using CFCs
- Examining a Sample Application
- Discussion
4The Main Concepts
- N-tier Architecture
- Logical Structure
- Division of the App on a conceptual level
- Physical Structure
- Directory Structure
- Server Clustering
5The Main Concepts (contd)
- CFCs
- What are CFCs?
- Based on Object Oriented Concepts
- Leverage the Strengths of OO Programming
- When do you use CFCs?
- Business Logic
- Data Access
6N-tier Architecture
- Logical Structure
- Presentation - UI
- Process Business Logic / Validation
- Data RDBMS / Stored Procs / Queries
- Physical Structure
- Form meets Function / CFC Packaging
- Directory Structure
- Server Environment
7CFCs
- What are CFCs?
- CFC ColdFusion Components
- CFCs are ColdFusion files, with one notable
exception they must have an extension of CFC - Reusable ColdFusion based objects that facilitate
code encapsulation and reuse
8CFCs (contd)
- Use CFCs when you need to
- Separate content or data from presentation code
- Write business logic and data calls that are
accessible by multiple front-end - Check for required parameters or validate
parameter data types
9CFCs (contd)
- CFC Terminology
- Methods equate to CFFUNCTION tags, which
encapsulate individual functions or uses for the
code within them - Arguments are parameters that are passed into the
CFC - Return Values are the values passed out of a
processed method
10CFCs (contd)
ltcfcomponentgt ltcffunction name"authenticate"
access"public" output"false"gt ltcfargument
name"user" type"string" required"true"/gt
ltcfargument name"passwd" type"string"
required"true"/gt ltcfquery
name"checkAuthentication" datasource"SecurityDB"
gt SELECT username FROM
Security WHERE username
arguments.user AND password
arguments.passwd lt/cfquerygt ltcfif
checkAuthentication.recordCountgt ltcfreturn
checkAuthentication.user/gt ltcfelsegt
ltcfreturn false/gt lt/cfifgt
lt/cffunctiongt lt/cfcomponentgt
11Invoking CFCs
- Using CFINVOKE
- CFOBJECT or CFSCRIPT
ltcfinvoke component"hogs_app._components.tally"
method"get_user_tallies" userid"url.uid"
returnvariable"getUserTallies"gt lt/cfinvokegt
12CFCs (contd)
- CFC Packaging
- Package by Process
- Refers to more than just saving them in the same
directory - Package name from Custom Tag directory or webroot
- By being aware of CFC packaging, you can invoke
package-accessible methods within another CFC
in the package
13Examining a Sample Application
- HogTallied Example
- Security
- Tallies
- Games
- Predictions
14Discussion