Code Examples: https://github.com/nolanerck/modern-cfml-demos
The recent versions of ColdFusion have added many new language features. We’ve now got closures, functional programming constructs, QueryExecute, the safe navigation operator, the Elvis operator, and even more coming in future releases. For people new to functional programming or object oriented programming, it can be hard to see where these features can be beneficial. Let’s fix that!
In this talk we’ll discuss many of the new language enhancements in CFML. But rather than stopping with an “x = 1” example, we’ll look at blocks of code that are more real-world in nature. The code demos will all be based on scenarios you’ll run across in your daily development. That's right, we'll run real live code! You'll get to see these language features in action, right before your very eyes!
6. Today's AgendaToday's Agenda
Look at new language features CFML
And related newer tools, etc
Discuss brie y what they do
And give non "hello world" examples of how to use
them
8. Install CommandBox!Install CommandBox!
Seriously
If you learn nothing else, learn this
Really is a game-changer
You do not have to be on ColdBox to use it
All the Node/npm fun from JavaScript for the CFML
world!
Packages, registry, CLI tools, server management
Written mostly in CFML
Easy to modify, contribute to, learn, update, etc
9. CommandBox...CommandBox...
Command line CFML tools
Incredibly easy to set up new environments
Switch to any version of CFML easily
REPL
Easy scaffolding for projects
Basically all the things Node developers brag
about
But for CFML!
My "CommandBox vs Node" preso from yesterday
12. TestBoxTestBox
Can test any CFML app
Not just ColdBox apps!
The better your code, the easier to test
But can be used to test old c ncludes, no-framework apps,
anything!
"TestBox for non-ColdBox Apps" preso
18. Closures are all over TestBoxClosures are all over TestBox
Testing code is always important
You can use TestBox to test any CF code
Not just for ColdBox projects
Can test c nclude, functions, custom tags,
whatever
Deson't need to be a ColdBox app
But you do need closures
19. But that's just how TestBox does it, right?But that's just how TestBox does it, right?
22. But please try not to do that. :)But please try not to do that. :)
23. Member FunctionsMember Functions
Really don't do anything different
Instead of ArrayLen( arr ), it's arr.length()
The "thing" has the function built inside
Similar to Java, Groovy, JavaScript, etc
Code looks more like other OO
languages
28. Member Functions ExamplesMember Functions Examples
Lots More too
ArrayMin(), max(), etc
Array Slicing
XML Member Functions
Numeric Member
Functions
33. Elvis, Ternary, and Safe NavigationElvis, Ternary, and Safe Navigation
All essentially short-hands for various if() statements
Elvis is ?:
Ternary is test-case ? expression : expression
Safe Navigation is
structName?.keyThatMayNotExist
42. QueryExecute()QueryExecute()
Cleaner way to execute queries in
CFScript
Less of the ".net" style block of code
Essentially one line of code
QueryExecute( sql, params, options );
57. built-in map(), reduce(),etc is pretty fastbuilt-in map(), reduce(),etc is pretty fast
Built-in functions
Can probably replace larger loops and custom logic in your
legacy apps
Code will look and behave similar to modern JavaScript stacks
too
59. Pick and ChoosePick and Choose
Don't have to change the entire app at once
Swap in a new language construct one at a time
Use TestBox to ensure you don't break
anything
None of these constructs are *box speci c!
Use them in your legacy apps!
60. Learning in 30 minutes a dayLearning in 30 minutes a day
61. Other ResourcesOther Resources
CFML Reference on helpx.adobe.com
cfdocs.org
"Head First Design Pattens" book
South of Shasta on-site and remote training
classes
Talk to people at the conference!