SlideShare a Scribd company logo
1 of 12
SCOPE YOUR VARIABLE
 Always specify Scope of variables, this tells
coldfusion where to look for variable value and
gain performance.
 What’s different between #URL.firstname# and
#firstname#?
 Scope Evaluation Sequence
 Arguments
 Variables (local scope)
 CGI
 URL
 Form
 Cookie
 Client
Use Boolean evaluation
 Avoid IS, NOT IS where ever possible.
 <cfif arguments.firstName IS “”> equal to
<cfif len(arguments.firstName) eq 0> equal
to
<cfif len(arguments.firstName)>
 All above statement work same only
difference is performance.
 And this become remarkable on high traffic
sites.
AVOID IsDefine
 How do you check form.firstName variable exist or
not?
 Really simple <cfif isDefined(“form.firstName”)>
 Ever try <cfif structKeyExists(form,”firstName”)>?
 Second Method gives you almost double performance
gain.
 User structure function instead of isDefined to check
existence.
 Session, form, application, URL, arguments all are
structure variable. (Believe me)
AVOID Evaluate()
 Evaluate is Evil.
 Generally we use Evaluate function get
value from dynamic variables name.
 From.text1, form.text2, form.text3 can be
obtain with evaluate(“form.text” & k) where k
varies from 1 to 3.
 Wait we have another way to do so.
○ Form[“text” & k] (K varies from 1 to 3)
 Second method gives around 3-5 times
performance gain.
Use of CFOUTPUT
 I think CFOUTPUT is most common tag
use by Cfer and most widely use in
application.
 Beware unnecessary use of any tag, it
cost.
 Performance Gain 2 to 8 times
<cfloop from=“1” to=“10”
index=“I”>
<cfoutput>#i#</cfoutput>
</cfloop>
<cfoutput>
<cfloop from=“1” to=“10”
index=“I”>
#i#
</cfloop>
</cfoutput
AVOID over use of #
 # often use to output variable values.
 <cfoutput>#name#</cfoutput>
 Sometimes to use variable in string.
 <cfset a = “Hello #name#”>
 Other than this I don’t think # sign needed.
 Do not use in.
 <cfset #name# = “John”>
 <cfif #name# eq “John”>
 Will not fire any error but we have lots of other
thing to load ColdFusion.
Use cfqueryparam
 Always use cfqueryparam.
 You are adding big security loop hole if
you are avoiding it.
 It also boost up performance.
Best Practice for CFC
 In CFC allow access to data associated with CFC
only.
 Do not use invoke or creating component to calling
function from same CFC.
 Avoid use of this as it for variable scope.
 CFC is component and do not use it for presentation
layer (view).
 Always use output = “false” for function and on
component. In case you need it return as string
instead of printing output in CFC.
 Do not directly refer to external variables (variables,
session, Application). In some case application
variable is ok but never use session or variables.
 Specify arguments type in function
arguments to avoid unnecessary error and
it improve security.
 Specify return type of function wherever
possible.
Best Practice…
 Create structure variable LOCAL using var
declaration.
 Specify scope as LOCAL for all function’s
variables.
○ Give more readability.
○ Avoid variable overwrite
Keep in Mind
 Variables type array, string, number and
dates all pass by value.
 Variables type structure, query and other
complex variable pass by reference.
Things we already know
 Always give well defined name of
variables.
 Use camel case for variable name and
avoid underscore.
 Always write something meaning full
comments instead of making it horrible.
E.g. “Very complex logic, do not touch
this code”. 
 Use hint in cffunction and cfargument.

More Related Content

What's hot

Immutability and pure functions
Immutability and pure functionsImmutability and pure functions
Immutability and pure functionssparkfabrik
 
Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)Achmad Solichin
 
Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Samyak Bhalerao
 
AngularJS Unit Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and JasmineAngularJS Unit Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and Jasminefoxp2code
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit TestChiew Carol
 
Confident Refactoring - Ember SF Meetup
Confident Refactoring - Ember SF MeetupConfident Refactoring - Ember SF Meetup
Confident Refactoring - Ember SF MeetupFastly
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSJim Lynch
 
AngularJS Unit Testing
AngularJS Unit TestingAngularJS Unit Testing
AngularJS Unit TestingPrince Norin
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmineTimothy Oxley
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsTest-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsFITC
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introductionNir Kaufman
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaAndrey Kolodnitsky
 
Swift testing ftw
Swift testing ftwSwift testing ftw
Swift testing ftwJorge Ortiz
 
Inline function(oops)
Inline function(oops)Inline function(oops)
Inline function(oops)Jay Patel
 

What's hot (20)

Immutability and pure functions
Immutability and pure functionsImmutability and pure functions
Immutability and pure functions
 
Les06
Les06Les06
Les06
 
Les06
Les06Les06
Les06
 
Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)
 
Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...
 
Angular testing
Angular testingAngular testing
Angular testing
 
Javascript: master this
Javascript: master thisJavascript: master this
Javascript: master this
 
Rspec
RspecRspec
Rspec
 
AngularJS Unit Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and JasmineAngularJS Unit Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and Jasmine
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit Test
 
Returning Data
Returning DataReturning Data
Returning Data
 
Confident Refactoring - Ember SF Meetup
Confident Refactoring - Ember SF MeetupConfident Refactoring - Ember SF Meetup
Confident Refactoring - Ember SF Meetup
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJS
 
AngularJS Unit Testing
AngularJS Unit TestingAngularJS Unit Testing
AngularJS Unit Testing
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmine
 
Test-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS ApplicationsTest-Driven Development of AngularJS Applications
Test-Driven Development of AngularJS Applications
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introduction
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and Karma
 
Swift testing ftw
Swift testing ftwSwift testing ftw
Swift testing ftw
 
Inline function(oops)
Inline function(oops)Inline function(oops)
Inline function(oops)
 

Viewers also liked

Bloggeraurreratua eusk
Bloggeraurreratua euskBloggeraurreratua eusk
Bloggeraurreratua euskKatalogador
 
Rep lesson
Rep lessonRep lesson
Rep lessonstoliros
 
Perlbeginnes 2 keynote
Perlbeginnes 2 keynotePerlbeginnes 2 keynote
Perlbeginnes 2 keynoteazuma satoshi
 
Mohamed Hamdan Resume
Mohamed Hamdan ResumeMohamed Hamdan Resume
Mohamed Hamdan Resumemoh_madi79
 
HECAT Overview
HECAT  OverviewHECAT  Overview
HECAT Overviewrmchpe
 
Media question 1
Media question 1Media question 1
Media question 1stoliros
 
Company overview
Company overviewCompany overview
Company overviewDynamizeIT
 
Kozma Szilárd: Nagy Attila Puli, avagy az árnyék én a sorsképlet tükrében
Kozma Szilárd: Nagy Attila Puli, avagy az árnyék én a sorsképlet tükrébenKozma Szilárd: Nagy Attila Puli, avagy az árnyék én a sorsképlet tükrében
Kozma Szilárd: Nagy Attila Puli, avagy az árnyék én a sorsképlet tükrébenVioletta Joó
 
Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)
Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)
Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)Alexey Lavrenuke
 
Manual Testing Questions
Manual Testing QuestionsManual Testing Questions
Manual Testing QuestionsUser1test
 
All-Pro Fasteners
All-Pro FastenersAll-Pro Fasteners
All-Pro FastenersTodd Grzych
 
Lectionline esaltazione della croce anno a
Lectionline esaltazione della croce anno aLectionline esaltazione della croce anno a
Lectionline esaltazione della croce anno aMaike Loes
 
Kozma Szilárd karma- és családasztrológusAz anyag titka
Kozma Szilárd karma- és családasztrológusAz anyag titkaKozma Szilárd karma- és családasztrológusAz anyag titka
Kozma Szilárd karma- és családasztrológusAz anyag titkaVioletta Joó
 
Максим Кравцов, Формула счастья
Максим Кравцов, Формула счастьяМаксим Кравцов, Формула счастья
Максим Кравцов, Формула счастьяNataly Bogdanova
 
A Story of Tiny Frog
A Story of Tiny FrogA Story of Tiny Frog
A Story of Tiny Frogbhatsumanta
 
Lectionline dedicazione della basilica lateranense
Lectionline dedicazione della basilica lateranenseLectionline dedicazione della basilica lateranense
Lectionline dedicazione della basilica lateranenseMaike Loes
 
Faculty presentation
Faculty presentationFaculty presentation
Faculty presentationstoliros
 

Viewers also liked (20)

Bloggeraurreratua eusk
Bloggeraurreratua euskBloggeraurreratua eusk
Bloggeraurreratua eusk
 
Rep lesson
Rep lessonRep lesson
Rep lesson
 
Perlbeginnes 2 keynote
Perlbeginnes 2 keynotePerlbeginnes 2 keynote
Perlbeginnes 2 keynote
 
Mohamed Hamdan Resume
Mohamed Hamdan ResumeMohamed Hamdan Resume
Mohamed Hamdan Resume
 
HECAT Overview
HECAT  OverviewHECAT  Overview
HECAT Overview
 
Media question 1
Media question 1Media question 1
Media question 1
 
Company overview
Company overviewCompany overview
Company overview
 
Mantra rus
Mantra rusMantra rus
Mantra rus
 
Febbraio
FebbraioFebbraio
Febbraio
 
Kozma Szilárd: Nagy Attila Puli, avagy az árnyék én a sorsképlet tükrében
Kozma Szilárd: Nagy Attila Puli, avagy az árnyék én a sorsképlet tükrébenKozma Szilárd: Nagy Attila Puli, avagy az árnyék én a sorsképlet tükrében
Kozma Szilárd: Nagy Attila Puli, avagy az árnyék én a sorsképlet tükrében
 
Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)
Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)
Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)
 
Manual Testing Questions
Manual Testing QuestionsManual Testing Questions
Manual Testing Questions
 
All-Pro Fasteners
All-Pro FastenersAll-Pro Fasteners
All-Pro Fasteners
 
Lectionline esaltazione della croce anno a
Lectionline esaltazione della croce anno aLectionline esaltazione della croce anno a
Lectionline esaltazione della croce anno a
 
Kozma Szilárd karma- és családasztrológusAz anyag titka
Kozma Szilárd karma- és családasztrológusAz anyag titkaKozma Szilárd karma- és családasztrológusAz anyag titka
Kozma Szilárd karma- és családasztrológusAz anyag titka
 
Gmm andate
Gmm andateGmm andate
Gmm andate
 
Максим Кравцов, Формула счастья
Максим Кравцов, Формула счастьяМаксим Кравцов, Формула счастья
Максим Кравцов, Формула счастья
 
A Story of Tiny Frog
A Story of Tiny FrogA Story of Tiny Frog
A Story of Tiny Frog
 
Lectionline dedicazione della basilica lateranense
Lectionline dedicazione della basilica lateranenseLectionline dedicazione della basilica lateranense
Lectionline dedicazione della basilica lateranense
 
Faculty presentation
Faculty presentationFaculty presentation
Faculty presentation
 

Similar to Cold fusion best practice

1669958779195.pdf
1669958779195.pdf1669958779195.pdf
1669958779195.pdfvenud11
 
JavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdfJavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdfranjanadeore1
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and ToolsBob Paulin
 
ColdFusion Components
ColdFusion ComponentsColdFusion Components
ColdFusion Componentsjsmith
 
Cordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptCordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptBinu Paul
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everythingnoelrap
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Codeerikmsp
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingVisual Engineering
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidenceJohn Congdon
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in reactBOSC Tech Labs
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy CodeNaresh Jain
 
Refactoring Simple Example
Refactoring Simple ExampleRefactoring Simple Example
Refactoring Simple Exampleliufabin 66688
 
Functional programming in Javascript
Functional programming in JavascriptFunctional programming in Javascript
Functional programming in JavascriptKnoldus Inc.
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming languageVasavi College of Engg
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoftch samaram
 
Some tips to improve developer experience with Symfony
Some tips to improve developer experience with SymfonySome tips to improve developer experience with Symfony
Some tips to improve developer experience with Symfonytyomo4ka
 
Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]srikanthbkm
 

Similar to Cold fusion best practice (20)

1669958779195.pdf
1669958779195.pdf1669958779195.pdf
1669958779195.pdf
 
JavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdfJavaScript Cheatsheets with easy way .pdf
JavaScript Cheatsheets with easy way .pdf
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and Tools
 
C# - Part 1
C# - Part 1C# - Part 1
C# - Part 1
 
ColdFusion Components
ColdFusion ComponentsColdFusion Components
ColdFusion Components
 
Final requirement
Final requirementFinal requirement
Final requirement
 
Cordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptCordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to Javascript
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everything
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Code
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
Refactoring Simple Example
Refactoring Simple ExampleRefactoring Simple Example
Refactoring Simple Example
 
Functional programming in Javascript
Functional programming in JavascriptFunctional programming in Javascript
Functional programming in Javascript
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
Some tips to improve developer experience with Symfony
Some tips to improve developer experience with SymfonySome tips to improve developer experience with Symfony
Some tips to improve developer experience with Symfony
 
Switch case and looping jam
Switch case and looping jamSwitch case and looping jam
Switch case and looping jam
 
Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]
 

Recently uploaded

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Recently uploaded (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

Cold fusion best practice

  • 1.
  • 2. SCOPE YOUR VARIABLE  Always specify Scope of variables, this tells coldfusion where to look for variable value and gain performance.  What’s different between #URL.firstname# and #firstname#?  Scope Evaluation Sequence  Arguments  Variables (local scope)  CGI  URL  Form  Cookie  Client
  • 3. Use Boolean evaluation  Avoid IS, NOT IS where ever possible.  <cfif arguments.firstName IS “”> equal to <cfif len(arguments.firstName) eq 0> equal to <cfif len(arguments.firstName)>  All above statement work same only difference is performance.  And this become remarkable on high traffic sites.
  • 4. AVOID IsDefine  How do you check form.firstName variable exist or not?  Really simple <cfif isDefined(“form.firstName”)>  Ever try <cfif structKeyExists(form,”firstName”)>?  Second Method gives you almost double performance gain.  User structure function instead of isDefined to check existence.  Session, form, application, URL, arguments all are structure variable. (Believe me)
  • 5. AVOID Evaluate()  Evaluate is Evil.  Generally we use Evaluate function get value from dynamic variables name.  From.text1, form.text2, form.text3 can be obtain with evaluate(“form.text” & k) where k varies from 1 to 3.  Wait we have another way to do so. ○ Form[“text” & k] (K varies from 1 to 3)  Second method gives around 3-5 times performance gain.
  • 6. Use of CFOUTPUT  I think CFOUTPUT is most common tag use by Cfer and most widely use in application.  Beware unnecessary use of any tag, it cost.  Performance Gain 2 to 8 times <cfloop from=“1” to=“10” index=“I”> <cfoutput>#i#</cfoutput> </cfloop> <cfoutput> <cfloop from=“1” to=“10” index=“I”> #i# </cfloop> </cfoutput
  • 7. AVOID over use of #  # often use to output variable values.  <cfoutput>#name#</cfoutput>  Sometimes to use variable in string.  <cfset a = “Hello #name#”>  Other than this I don’t think # sign needed.  Do not use in.  <cfset #name# = “John”>  <cfif #name# eq “John”>  Will not fire any error but we have lots of other thing to load ColdFusion.
  • 8. Use cfqueryparam  Always use cfqueryparam.  You are adding big security loop hole if you are avoiding it.  It also boost up performance.
  • 9. Best Practice for CFC  In CFC allow access to data associated with CFC only.  Do not use invoke or creating component to calling function from same CFC.  Avoid use of this as it for variable scope.  CFC is component and do not use it for presentation layer (view).  Always use output = “false” for function and on component. In case you need it return as string instead of printing output in CFC.  Do not directly refer to external variables (variables, session, Application). In some case application variable is ok but never use session or variables.
  • 10.  Specify arguments type in function arguments to avoid unnecessary error and it improve security.  Specify return type of function wherever possible. Best Practice…  Create structure variable LOCAL using var declaration.  Specify scope as LOCAL for all function’s variables. ○ Give more readability. ○ Avoid variable overwrite
  • 11. Keep in Mind  Variables type array, string, number and dates all pass by value.  Variables type structure, query and other complex variable pass by reference.
  • 12. Things we already know  Always give well defined name of variables.  Use camel case for variable name and avoid underscore.  Always write something meaning full comments instead of making it horrible. E.g. “Very complex logic, do not touch this code”.   Use hint in cffunction and cfargument.