The world of software development is ever-changing. It’s only a matter of time before current code becomes legacy which eventually becomes obsolete. The number one way to counteract this growth is to actually modernize alongside. Modernization not only keeps you current but allows for you to utilize better technologies. Adobe ColdFusion alone has been through many changes over the years, mostly for good. In Nolan Erck’s upcoming session at the 2018 CF Summit in Las Vegas, he will present to intermediate and veteran CF’ers practical applications past CFML theory. Let’s talk about the importance of modernization from a CIO standpoint and some real-world applications for modern CFML.
“CFML has become a completely modern language. I'm proud to use CF because it is a great language. It has its quirks but hey, show me a language that doesn’t.”- Mark Drew, Director at CMD
From CF Alive episode, “035 Getting started fast with Docker, with Mark Drew“
What You Need to Know as CIO
To explain IT modernization, you need to understand what IT modernization is not. Modernization is not a destination. It is not an achievable concrete goal. IT modernization is a never-ending journey. Does that mean you shouldn’t take the first step though? Hell no. Software and IT technologies will not slow down for you or your business. Do not slow down for them. Modernization is more than just updating your servers and versions– although those are important to do. It involves changes in your technologies, employees, processes, talents, and strategies. There are many reasons why companies don’t modernize. Lack of resources. The time required for new training. Yet, the number one reason CIOs and companies don’t modernize is fear of change. Most people, in general, choose to stay in their comfort zones. Learning something new without knowing the benefits can be off-putting. Conferences, such as the 2018 CF Summit or CF Camp in Munich, are great opportunities to learn more about the modernization journey you intend to take with your CFML.
Why modernize in the first place? It’s simple. Modernization will help your business. Plain and simple. One of the first processes to modernization is to the cloud. Not just one cloud either. Studies have shown that smoother operation and deployments of your IT demands come from a hybrid cloud. This hybrid cloud can be made up of multiple public clouds, a private cloud, and possibly a legacy cloud comprised of a company’s legacy estate. This not only allows for smooth operations but also cuts down the cost of maintaining and operating private servers– both legacy and modern. Aside from cloud computing, Agile methodologies and DevOps are helping modern companies to pick up the pace of their IT change. CIO.com explains DevOps as such:
“DevOps uses cross-functional teams aligned by business services. The teams are responsible for the entire stack that was delivered in shared services. They are persistent teams, staying with the firm throughout its transformation journey, rather than moving on to other projects. DevOps teams are also located in close proximity with the business teams to enhance collaboration and increase speed. Unlike shared services units, which focus on low costs per function, DevOps focuses on business impact at speed. Consequently, as companies take the DevOps journey, they use dramatically fewer resources to deliver services.”
Fewer resources with better faster results? It’s clear to see why these processes are important.
So, where would you even begin to start modernizing? Check out these tips to embark on your journey to modernization.
-
Figure Out Your Current System
- You cannot change direction if you don’t know where your company stands in the first place. Learn the ins and outs of your system so you can properly develop a roadmap to modernization.
-
Empower your Employees
- Providing managerial pressure may work in some circumstances, but it is not the case here. Instead, empower your employees with a meaningful mission. Your employees need to be along for the ride as well. Help them help you by using these handy tools from Intuitive Leadership Mastery.
-
Keep Your Consultants Close
- IT Modernization may require some outside help, especially if your company is extremely outdated. Co-design your modernization roadmap together, and make sure they are at all of your progress meetings.
-
Create a Plan with Achievable Milestones
- Having a plan with actual milestone goals can help out tremendously. They can show you exactly where your company’s progress is and the direction it is heading. Achieving goals is also a great morale booster and motivator for you and your team.
-
Establish a PMO
- A PMO is a Project Management Office– or Officer. Establish a dedicated group or individual responsible for overseeing your IT Modernization. This will allow some of the stress to roll off you and create free time for you to focus on other much-needed company tasks.
-
The Main Goal is Agility
- IT Modernization revolves around one key concept. Agility. Your modernization efforts should focus on the ability for your company and applications to scale quickly. The IT world is rapidly changing. Make sure your business can keep up. For more on the benefits of agility and speed, check out this article on Speed vs Control.
-
Reusable and Premade Modules
- During your IT modernization process, you will end up creating helpful modules that you can use again and again (particularly when modernizing your CFML). Make a catalog of these that you can recall as need be. Even better, share with other companies that may be able to use them. A great place to share your CFML modules and packages is on ForgeBox. Here you can share with others or find modules that you may need for your modernization efforts.
“…nobody is going to come work for procedural programming. I mean nobody. No wonder nobody wants to go do ColdFusion because they don’t want to be working with procedural code. So if corporations don’t do this, ColdFusion will not be alive anymore. So the corporations really need to modernize. That’s the first thing.” – Luis Majano, President of Ortus Solutions
From CF Alive episode, “012 Extreme Testing and Slaying the Dragons of ORM with Luis Majano“
Tech Talk
In this Tech Talk, let’s take a look at three areas of modern CFML.
Closures and Functional Programming Constructs
A functional programming language is a one that focuses on immutable data and functions. Because building blocks in functional programming languages are actually functions –not components as ColdFusion– it is very common to pass functions as arguments. Likewise, return functions pass as results. With the advent of ColdFusion 10, Adobe introduced closures allowing CF to act as a functional programming language in some regards. Closures are inner functions. These inner functions access the variables in outer functions. In turn, you can access the inner function by accessing the outer function.
Adobe provides a great example when discussing closures.
<cfscript> function helloTranslator(required String helloWord) { return function(required String name) { return "#helloWord#, #name#"; } ; } helloInFrench=helloTranslator("Bonjour") writeOutput(helloInFrench("John")) </cfscript>
In the above example, the outer function returns a closure. Using the helloHindi variable, the outer function is accessed. It sets the helloWord argument. Using this function pointer, the closure is called.
Although not very widespread in the CF Community as of now, we can see these closures take form in functions such as arrayMap() and arrayFilter(). Other examples of closures include the latest version of FW/1 and TestBox. FW/1 uses closures to provide a “builder” style syntax for developing REST API results. TestBox uses closures rather extensively when performing their BDD tests– be sure to catch up on BDD tests with Uma Ghotikar.
Scope of Closure
This table from Adobe highlights the scope of variously defined closures in ColdFusion.
Scenario where closure is defined | Scope |
In a CFC function | Closure argument scope, enclosing function local scope and argument scope, this scope, variable scope, and superscope |
In a CFM function | Closure argument scope, enclosing function local scope and argument scope, this scope, variable scope, and superscope |
As function argument | Closure argument scope, variable scope, and this scope and super scope (if defined in CFC component). |
ColdFusion has seen its fair share of smooth operators, conditional and binary that is. (Or its Development Community, *wink wink*) Let’s take a look at the evolution of operators through ColdFusion.
Ternary Operator
Along with the release of ColdFusion 9 came the ternary operator. The Ternary Operator is a decision-making operator that requires three operands.
-
Condition
-
True Statement
-
False Statement
These three components are combined using a question mark (?) and colon (:).
((condition) ? trueStatement : falseStatement)
This operator was great when it was released. It was often used to conditionally transform or default method arguments. Ben Nadal once claimed that the ternary operator is everything that the IIF() method call wanted to be. The way the operator worked was by evaluating the condition given. If it was false, the false statement would be executed. Vice versa if the condition was true.
The ternary operator came with a downside though. Although its shorthand notation was much easier to write, it was also much harder to read.
Elvis Operator
In ColdFusion 11 or Splendor, the Elvis Operator debuted. The Elvis operator is a binary operator and was introduced in a ?: format. It strove to shorten your conditional code and make it more elegant. The main purpose of the Elvis operator in ColdFusion is to assign the right default for a variable or an expression. In an expression, if the resultant value is not defined, then the object will be assigned to the leftmost part of the expression otherwise a default value (define at the rightmost part) will be assigned.
myDisplayName = userName ?: “Anonymous”;
In the above example, if userName is defined, it will be assigned to the myDisplayName variable. If the userName is not defined, the value “Anonymous” will be assigned to the myDisplayName variable.
See the following example:
employeeName = getEmployeeName(ID) ?: “Joe”;
In the above example, if getEmployeeName(ID) does not return any value, the value “Joe” will be assigned to the employeeName variable.
You can also use this operator for Struct:
securityNumber = securityStruct[‘Joe’] ?: “”;
The latest in Adobe’s line of operators is the Safe Navigation Operator. Released in 2016, the Safe Navigation operator is designed to increase the productivity of CFML developers. Before in your CFML apps, developers used safe checks as follows:
if(isDefined(“myvar”) && !isNull(myvar))
Nested structs had even more checks. But with the safe navigation operator, safe navigation is shown as follows.
writeOutput(myvar?.firstlevel?.nextlevel?.udf()?.trim());
The question mark operator along with the dot operator make up the safe navigator operator. It makes sure that your previously used variable is not defined or java null. Instead of posting an error, the function returns undefined for that particular access. The great thing about the safe navigation operator is that it can be used at all levels. Even if a single element in a string does not exist, the access will return as undefined. It can be used for both function calls or function and struct access combined. You can also use it in conjunction with the Elvis operator. The safe navigation operator can really help developers process their code with agility and better performance.
What are CFquery Tags and QueryExecute? Cfquery tags pass queries or SQL statement along to a data source. These tags are primarily used to execute SQL statements. They can be used for any SQL DDL (Data Definition Language) or DML(Data Manipulation Language) statement. Mostly though, you will use them to execute SQL SELECT statements. Cfquery tags also return the following result variables in a structure:
Variable name | Description |
result_name.sql | The SQL statement that was executed. |
result_name.recordcount | Number of records (rows) returned from the query. |
result_name.cached | True if the query was cached; False otherwise. |
result_name.sqlparameters | An ordered Array of cfqueryparam values. |
result_name.columnList | Comma-separated list of the query columns. |
result_name.ExecutionTime | Cumulative time required to process the query. |
result_name.IDENTITYCOL | SQL Server only. The ID of an inserted row. |
result_name.ROWID | Oracle only. The ID of an inserted row. This is not the primary key of the row, although you can retrieve rows based on this ID. |
result_name.SYB_IDENTITY | Sybase only. The ID of an inserted row. |
result_name.SERIAL_COL | Informix only. The ID of an inserted row. |
result_name.GENERATED_KEY | MySQL only. The ID of an inserted row. MySQL 3 does not support this feature. |
result_name.GENERATEDKEY | Supports all databases. The ID of an inserted row. |
These results can be then cached and execute stored procedures. Remember, when using Cfquery tags, use them in conjunction with Cfqueryparam to help secure your databases from SQL injection.
QueryExecute is a differentiation from the standard Cfquery tag. It simplifies the execution in the CFScript block. QueryExecute allows you to pass unnamed parameters within the query itself. Simply use a question mark as a placeholder for the unnamed parameter. It may be used as an independent function apart from the standard Cfquery tag.
These are just a few modern tools that you can take advantage of when using CFML and Adobe ColdFusion. Remember, modernization is not here to give you aches and pains. It is here to help. Update your platform –if need be– and join modern CFML today!
About the Speaker: Nolan Erck has been a software developer for the past 12 years. Starting in the multi-billion dollar video game industry, he was credited with both Maxis and LucasArts. Currently, Nolan manages the SacInteractive Group and South of Shasta Consulting.
And to continue learning how to make your ColdFusion apps more modern and alive, I encourage you to download our free ColdFusion Alive Best Practices Checklist.
Because… perhaps you are responsible for a mission-critical or revenue-generating CF application that you don’t trust 100%, where implementing new features is a painful ad-hoc process with slow turnaround even for simple requests.
What if you have no contingency plan for a sudden developer departure or a server outage? Perhaps every time a new freelancer works on your site, something breaks. Or your application availability, security, and reliability are poor.
And if you are depending on ColdFusion for your job, then you can’t afford to let your CF development methods die on the vine.
You’re making a high-stakes bet that everything is going to be OK using the same old app creation ways in that one language — forever.
All it would take is for your fellow CF developer to quit or for your CIO to decide to leave the (falsely) perceived sinking ship of CFML and you could lose everything—your project, your hard-won CF skills, and possibly even your job.
Luckily, there are a number of simple, logical steps you can take now to protect yourself from these obvious risks.
No Brainer ColdFusion Best Practices to Ensure You Thrive No Matter What Happens Next
ColdFusion Alive Best Practices Checklist
Modern ColdFusion development best practices that reduce stress, inefficiency, project lifecycle costs while simultaneously increasing project velocity and innovation.
√ Easily create a consistent server architecture across development, testing, and production
√ A modern test environment to prevent bugs from spreading
√ Automated continuous integration tools that work well with CF
√ A portable development environment baked into your codebase… for free!
Learn about these and many more strategies in our free ColdFusion Alive Best Practices Checklist.