Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

ITB2019 Real World Scenarios for Modern CFML - Nolan Erck

57 views

Published on

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!

Published in: Technology
  • Be the first to comment

ITB2019 Real World Scenarios for Modern CFML - Nolan Erck

  1. 1. Real World Scenarios For Modern CFMLReal World Scenarios For Modern CFML Nolan Erck South of Shasta Consulting
  2. 2. About MeAbout Me Software Consultant (southofshasta.com) Software Development, Training, Design ColdFusion, C++, Java, jQuery, PHP, Angular, Android, SQL, etc... Manager, SacInteractive User Group Reformed Video Game Developer (Grim Fandango, SimPark, StarWars Rogue Squadron, etc). Music Junkie
  3. 3. Code And SlidesCode And Slides github.com/nolanerck modern-cfml-demos
  4. 4. 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
  5. 5. First real-world tipFirst real-world tip
  6. 6. 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
  7. 7. 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
  8. 8. Second Real World Tip...Second Real World Tip...
  9. 9. Install TestBox!Install TestBox!
  10. 10. 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
  11. 11. box install testbox...boom, donebox install testbox...boom, done
  12. 12. ClosuresClosures Not a CFML speci c feature Common in modern JavaScript Run code in its own "context" What the heck does that mean?
  13. 13. ClosuresClosures Example from CFDocs.org
  14. 14. Testbox Closure ExampleTestbox Closure Example
  15. 15. Testbox Closure ExampleTestbox Closure Example
  16. 16. 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
  17. 17. But that's just how TestBox does it, right?But that's just how TestBox does it, right?
  18. 18. Angular Closure ExampleAngular Closure Example
  19. 19. They also work in CF tags!They also work in CF tags!
  20. 20. But please try not to do that. :)But please try not to do that. :)
  21. 21. 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
  22. 22. Member Functions ExamplesMember Functions Examples
  23. 23. Member Functions ExamplesMember Functions Examples
  24. 24. Member Functions On a LiteralMember Functions On a Literal
  25. 25. Member Functions On a LiteralMember Functions On a Literal
  26. 26. Member Functions ExamplesMember Functions Examples Lots More too ArrayMin(), max(), etc Array Slicing XML Member Functions Numeric Member Functions
  27. 27. But which syntax is faster?But which syntax is faster?
  28. 28. It doesn't matterIt doesn't matter
  29. 29. Okay so why use it?Okay so why use it?
  30. 30. Modernize...or die!Modernize...or die!
  31. 31. 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
  32. 32. Elvis OperatorElvis Operator
  33. 33. Elvis OperatorElvis Operator
  34. 34. Ternary OperatorTernary Operator
  35. 35. Safe Navigation OperatorSafe Navigation Operator
  36. 36. But which syntax is faster?But which syntax is faster?
  37. 37. It doesn't matterIt doesn't matter
  38. 38. Okay so why use it?Okay so why use it?
  39. 39. Modernize...or die!Modernize...or die!
  40. 40. 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 );
  41. 41. QueryExcute() Older SyntaxQueryExcute() Older Syntax
  42. 42. QueryExecute()QueryExecute()
  43. 43. QueryExecute()QueryExecute()
  44. 44. this.datasource in Application.cfcthis.datasource in Application.cfc this.datasource = "moviesdsn"
  45. 45. But which syntax is faster?But which syntax is faster?
  46. 46. It doesn't matterIt doesn't matter
  47. 47. Okay so why use it?Okay so why use it?
  48. 48. Modernize...or die!Modernize...or die!
  49. 49. Functional ProgrammingFunctional Programming lter() map() reduce() Convert queries to arrays for better APIs, etc
  50. 50. map()map() Takes an array of things, runs the closure on each item Similar to a for() loop But closures have "context"
  51. 51. map() examplemap() example
  52. 52. reduce() examplereduce() example
  53. 53. But which syntax is faster?But which syntax is faster?
  54. 54. built-in map(), reduce(), etc is pretty fastbuilt-in map(), reduce(), etc is pretty fast
  55. 55. 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
  56. 56. Modernize...or die!Modernize...or die!
  57. 57. 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!
  58. 58. Learning in 30 minutes a dayLearning in 30 minutes a day
  59. 59. 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!
  60. 60. Questions? Comments?Questions? Comments? Need consulting help?Need consulting help? southofshasta.com nolan@southofshasta.com Twitter: @southofshasta Github: nolanerck github.com/nolanerck/modern-cfml-demos Thanks!

×