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

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

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.