Learn CFML With the ColdFusion Koans

The Koans walk you along the path to enlightenment in order to learn CFML. The goal is to learn the CFML language, syntax, structure, and some common functions and libraries. We also teach you culture. Testing is not just something we pay lip service to, but something we live. It is essential in your quest to learn and do great things in the language.

The Structure

ColdFusion Koans files

The koans are broken out into areas by file, arrays are covered in AboutArrays.cfc, components are introduced in AboutComponents.cfc, etc. They are presented in order in the home page, index.cfm. This is your path to enlightenment.

Each koan builds up your knowledge of CFML and builds upon itself. It will stop at the first place you need to correct.

Some koans simply need to have the correct answer substituted for an incorrect one. Some, however, require you to supply your own answer. If you see the method __ (a double underscore) listed, it is a hint to you to supply your own code in order to make it work correctly.

Installing

In order to run the koans you need a CFML ebgube installed. If you do not already have a CFML engine setup, please visit for specific instructions:

Installing the Koans

Installing the Koans is easy. Click on the "DOWNLOAD THE KOANS" button for the Koans zip file. Extract this file somewhere in your webroot. You may want to rename the folder from "bittersweetryan-ColdFusion-Koans-xxxxxxx" to ColdFusion-Koans.

To verify your installation, in your browser type in the url for your server along with the folder name for the koans and you should see a welcome page.

What Editors Can I Use?

You can really use any editor you'd like, but here are some suggestions:

The Path to Enlightenment

You can run the tests by calling the index.cfm page.

Red, Green, Refactor

In test-driven development (TDD) the mantra has always been red: write a failing test and run it, green: make the test pass, and refactor: look at the code and see if you can make it any better.

With the koans, you will need to run the tests and see it fail (red), make the test pass (green), then take a moment and reflect upon the test to see what it is teaching you and improve the code to better communicate its intent (refactor).

The very first time you run it you will see the following output:

First time running CFML Koans

You have come to the first error. Notice you are told where to look for the error: Koans.AboutAsserts and the testTrueShouldBeTrue method.

You then open up the AboutAsserts.cfc file under the Koans directory in your text editor and look at the testTrueShouldBeTrue method:

public void function testTrueShouldBeTrue(){
  //try replacing false with true
  assertTrue(false);
}

You then change false to true and run the tests again. You should get a new error.

Before moving on, think about what you are learning.

In this specific case, ignore everything except the method name (testTrueShouldBeTrue) and the parts inside the method (everything before the end). The goal is for you to see that if you pass a value to the assert method, it will either ensure it is true and continue on, or fail if in fact the statement is false.

Authors

Ryan Anklam

@bittersweetryan

Mike Henke

@mikehenke


License

ColdFusion Koans is released under a Creative Commons, Attribution-NonCommercial-ShareAlike License. @coldfusionkoans


Inspiration

A special thanks to Ruby Koans and the JavaScript Koans for inspiring this project, MXUnit for the unit testing framework for ColdFusion developers, and EdgeCase for the design of the site.

EdgeCase edgecase.com

Other Resources

ColdFusion Koans Issue Tracker github.com/bittersweetryan/ColdFusion-Koans/issues

ColdFusion Koans on Github github.com/bittersweetryan/ColdFusion-Koans

CFML in 100 minutes github.com/mhenke/CFML-in-100-minutes

John Farrar's ColdFusion 9 Developer Tutorial amazon.com/ColdFusion-Developer-Tutorial/dp/1849690243/

Matt Gifford's Object-Oriented Programming in ColdFusion amazon.com/Object-Oriented-Programming-CFML/dp/1847196322/

Mountains are merely mountains