The Adobe ColdFusion 8 Developer Exam arrived earlier this year and it is about time I took it. But like Ben Nadel, the exam scares me! Why? Because there is so much more to know. With the introduction of new AJAX tags, native JSON support, .NET integration, image manipulation, threading, interfaces, not to mention full PDF integration, the presentation builder and across the board enhancements, there are a lot of new things to know.

If it wasn’t for the fact that I am also an Adobe Certified Trainer, I would probably shy away from taking the exam, since, apart from showing that I have gained an Advanced level of knowledge of what’s available in the language/application, is it really relevant?

Now for the moan…

I like to prepare for exams properly. I studied hard for the CFMX6.1 and CFMX7 exams because I wanted to achieve the best result I possibly could. I don’t much like the stigma of mediocrity, so I try hard. But with the advent of the ColdFusion 8 exam, Adobe aren’t making life any easier and this isn’t because of the increased number of features. It’s because they are not supporting their exam with the appropriate study material.

In the past, Ben Forta had been commissioned to create the official developer study guide. However, according to Ben, this appears no longer to be the case (at least for now).

It beggars belief that Adobe release a product, then release a related exam, but do not have the will to produce a study guide. Yes we have the Web Application Construction Kit and Livedocs, but for me, they are either not succinct enough or not available in print. It makes it tough to study.

Clearly there is a cost issue, but Adobe Publishing can be smarter these days with their print-runs. Indeed they could even allow developers to choose between a print and PDF versions, much like Manning and many other publishers.

Perhaps Ben is busy. Surely not! But if it is the case, I’m sure there are a number of his peers that could take up the mantle. Cue…

A ray of hope…

There is a small ray of hope. There is likely to be an updated version of the popular CFMX Exam Buster by CentraSoft. Brian Simmons is working hard on the latest version.

In an earlier post I eluded to the implicit creation of arrays in ColdFusion 8. Well, the same can be said of structures.

A structure, also known as an associative array, is a complex data type composed of a collection of keys and a collection of values, where each key is associated with one value (a key-value pair). The operation of finding the value associated with a key is called a lookup or indexing, and this is the most important operation supported by a structure. The relationship between a key and its value is sometimes called a mapping or binding. For example, if the value associated with the key “Age” is 29 and “City” is “London”, we say that our structure maps “Age” to 29 and “City” to “London”.

Using structures, you can call the array element you need using a string rather than a number, which is often easier to remember. The downside is that these aren’t as useful in a loop because they do not use numbers as the index value.

We can think of an address book as a good example of a structure. The classic way of creating and assigning key-values pairs to a structure, in earlier versions of ColdFusion, would be as follows:

<cfscript>
strPerson = structNew();
strPerson.firstName = "Jean";
strPerson.lastName = "Dupont";
strPerson.city = "Paris";
</cfscript>

Or an alternative method uses array-notation to create the necessary key-value pairs:

<cfscript>
strPerson = structNew();
strPerson["Firstname"] = "Hans";
strPerson["Lastname"] = "Mustermann";
strPerson["Country"] = "Germany";
</cfscript>

NB. When using the array-notation, the key names keep their case. However, running the following code results in the value “France” being overwritten with “Germany”, even though the key name is a different case. This serves to highlight that ColdFusion is not case-sensitive.

<cfscript>
strPerson = structNew();
strPerson["Country"] = "France";
strPerson["COUNTRY"] = "Germany";
</cfscript>

Implicit Structures

With the introduction of implicit structures in ColdFusion 8, the creation of structures is greatly simplified. For example, rather than having to use the structNew() function, we can now simply do the following:

Using strings for values:

<cfscript>
myStruct = {firstname="Simon", lastname="Whatley", city="London"};
</cfscript>

Implicit Structures - Strings as Keys and Values

Using integers for values:

<cfscript>
myStruct = {account_no=12345678, sort_code=123456};
</cfscript>

Implicit Structures - Integers as Values

Using integers as keys:

This example most closely represents an array since arrays have numeric keys.

<cfscript>
myStruct = {10001="John", 10002="Doe", 10003="New York"};
</cfscript>

Implicit Structures - Integers as Keys

The integer could represent the unique identifier of an object, for example, user ID or order ID. Therefore, if we had nested structures like below, 10001 would be the ID of Simon Whatley, whilst 10002 would be the ID of John Doe.

<cfscript>
myStruct1 = {firstname="Simon", lastname="Whatley", city="London"};
myStruct2 = {firstname="John", lastname="Doe", city="New York"};
myStruct3 = {10001=myStruct1, 10002=myStruct2};
</cfscript>

Implicit Structures - Nested Structures

Mixed data types:

It is possible to mix the data types in an structure. For example, we can use an Integer, String and Array as elements within an array, with no problems. Since we need to know the key name before accessing the value, it is also likely we will know the type of the value and will be able to handle it accordingly. However, never assume this is always the case, so type checking is necessary when retrieving the data.

The example below demonstrates the ability to add arrays to structures.

<cfscript>
myArray1 = [1,2,3];
myArray2 = ["One","Two","Three"];
myStruct = {array1=myArray1, array2=myArray2};
</cfscript>

Implicit Structures - Nested Arrays

Structures, by their nature, cannot be sorted by value, only by the key name. They are best for related data, where order is not important and direct access to an individual element is important. Many of ColdFusion’s variable scopes can be accessed as structures, for example, Server, Application, Session and Variables etc.

Words of Caution

Implicit structures do have their limitations. For example, you cannot nest implicit struct, or indeed array, creation.

<cfscript>
myStruct1 = {
	myStruct2 = {
		firstName = "Jean",
		lastName = "Dupont",
		country = "France"
	},
	myStruct3 = {
		firstName = "Juan",
		lastName = "Pablo",
		country = "Spain"
	}
}
</cfscript>

The above will throw the following parsing error:

coldfusion.compiler.ParseException: 
Invalid CFML construct found on line 3 at column 10.

UPDATE: The recent ColdFusion Update now includes the ability to nest implicit structures.

To get around this problem, you can create each structure individually and then use the structure as the value in a key-value pair (as seen in the nested structure example above).

A (possible) strength of ColdFusion is that you can add key-value pairs as many times as is necessary. This is the same for explicit and implicit structure creation. However, the following code and screenshot serves to demonstrate that whether you explicitly or implicitly create a structure, if you duplicate a key, the last key-value pair in the sequence is the one that is represented in the structure:

<cfscript>
myStruct = {
	firstName = "Jean",
	lastName = "Dupont",
	country = "France",
	country = "Germany"
};
</cfscript>

Implicit Structures - Duplicate Keys

A great new feature of ColdFusion 8 is its new implicit creation of Arrays and Structures. In addition to the updates to operators in ColdFusion, those of you familiar with JavaScript will recognise and welcome these changes.

An array is a data structure consisting of a group of elements that are accessed by indexing. In most programming languages each element has the same data type. However, ColdFusion, as we will see, is not strictly typed and therefore allows any data type to be stored in combination. This allows strings, integers, booleans and other complex data types all to be stored in the same array. However, doing this certainly isn’t a good practice as it causes signification complication when accessing the stored data.

Variables of a simple data type commonly only store a single value but, in some situations, it is useful to have a variable that can store a series of related values - using an array. Arrays are described as complex data types because they can hold data in a structured, complex way.

For example, suppose a routine is required that will calculate the average age among a group of six students. The ages of the students could be stored in six integer variables, added together and then divided by 6:

<cfscript>
age1 = 19;
age2 = 20;
age3 = 21;
age4 = 22;
age5 = 23;
age6 = 18;
 
average_age = (age1 + age2 + age3 + age4 + age5 + age6) / 6;
 
writeOutput(average_age); // returns 20.5
</cfscript>

However, a better solution would be to store the data in a six-element array and calculate the average age based upon the sum or the ages and the array length:

<cfscript>
age = arrayNew(1);
age[1] = 19;
age[2] = 20;
age[3] = 21;
age[4] = 22;
age[5] = 23;
age[6] = 18;
 
sum_age = 0;
 
//loop over the age array adding age together all ages
for (i = 1; i <= arrayLen(age); i++)
{
    sum_age += age[i];
}
 
//calculate the average age
average_age = sum_age / arrayLen(age);
 
writeOutput(average_age); // returns 20.5
</cfscript>

This is a few more lines of code, but allows for the flexibility of increasing or decreasing the number of elements (in this case ages) in the array, with no impact upon the core calculation.

NB: Unlike other programming languages, ColdFusion array indexes start from 1 not 0 (zero).

Implicit Arrays

With the introduction of implicit arrays in ColdFusion 8, the creation of arrays is greatly simplified. For example, rather than having to use the arrayNew(1) function, we can now simply do the following:

<cfscript>
myArray1 = [1,2,3]; //integers
</cfscript>

Implicit Arrays - Integer Example

This means that we can take the age calculation from ealier, and make the code even simpler to write:

<cfscript>
//implicity create the age array
age = [19,20,21,22,23,18];
 
sum_age = 0;
 
//loop over the age array adding age together all ages
for (i = 1; i <= arrayLen(age); i++)
{
    sum_age += age[i];
}
 
//calculate the average age
average_age = sum_age / arrayLen(age);
 
writeOutput(average_age); // returns 20.5
</cfscript>

Further examples

The following code snippets serve to exemplify my earlier comment that arrays can store any data type and indeed, any data type in combination.

Using strings:

<cfscript>
myArray2 = ["One","Two","Three"]; //strings
</cfscript>

Implicit Arrays - String Example

Using complex data types:

<cfscript>
myArray3 = [myArray1,myArray2]; //complex types (arrays)
</cfscript>

Implicit Arrays - Variables Example

Using implicit structures:

<cfscript>
myStruct1 = {firstname="Simon", lastname="Whatley", city="London"};
myStruct2 = {firstname="John", lastname="Doe", city="New York"};
myArray = [myStruct1, myStruct2];
</cfscript>

Implicit Arrays - Complex Example

The last two examples above serve to demonstrate that any complex data type can be used in conjuction with an array. This has not changed between ColdFusion version 7 and 8.

Mixing data types:

Although certainly not good practice, it is possible to mix the data types in an array. For example, we can use an Integer, String and Array as elements within an array, with no problem. However, it is when accessing this data that problems will arise.

<cfscript>
myArray4 = [1,"Two",myArray2];
</cfscript>

Implicit Arrays - Combined Example

Although the ColdFusion engine is not strict with regard to what data types are used within an array, always stick to the same type for each element.

Words of Caution

Implicit arrays do have their limitations. For example, you cannot nest implicit array, or indeed struct, creation.

<cfscript>
arrayOne = [
	arrayTwo = [1,2,3],
	arrayThree = [4,5,6]
]
</cfscript>

The above will throw the following parsing error:

coldfusion.compiler.ParseException: 
Invalid CFML construct found on line 3 at column 13.

UPDATE: The recent ColdFusion Update now includes the ability to nest implicit arrays.

A few months ago I posted an article on Installing Apache on Vista, and it proved to be extremely popular. It appears that I was not the only one who found it a non trivial matter.

Now it is the turn of ColdFusion 8. ColdFusion 8 as we well know is the latest and greatest incarnation of the ColdFusion platform from Adobe. It has a lot of great new features such as cfimage, cfzip, cfexchange, some contentious features such as cfthread and cfinterface, and some not-so-necessarily-cool new “Web 2.0″ features such as cffeed and cfajax. But since this article isn’t about any of these, I better stick to the topic.

Like my article on installing Apache, installing ColdFusion on Vista is again not a trivial matter and involves only what can colloquially described as a “shed load of steps”. I’m probably being a little harsh towards ColdFusion as many of the problems I encountered were more closely related to Apache than ColdFusion.

NB: This article will assume that you have pre-installed Apache (although you could use IIS if so compelled), turned off Vista’s User Account Control (UAC), disabled any firewalls you have installed and finally, but most importantly, you have downloaded ColdFusion from the Adobe website.

Let us begin.

  1. Find where you downloaded your copy of the ColdFusion Installer. Right-click on the executable file and specify to “Run as Administrator”. The installer should start and you should see the screenshot below. Select “English”, or which ever your language preference is, and Click “OK”.

    1. ColdFusion Installer

  2. The ColdFusion Installation progress screen may or may not be briefly displayed.

    2. ColdFusion Installation Progress

  3. The Introduction screen will be displayed. Click “Next”.

    3. Introduction Screen

  4. The License Agreement screen will then be displayed. Agree to the “I accept the terms of the License Agreement” and Click “Next”.

    4. License Agreement

  5. The Install Type screen is then displayed. You don’t need to enter a serial number unless you are installing this into a production environment. Check “Developer Edition” and Click “Next”.

    5. Install Type

  6. The Installer Configuration screen should be displayed. Since we already have Apache 2.x installed as our web server (if you want to use IIS, you will need to skip steps 11.1 and 11.2), check “Server configuration” and Click “Next”.

    6. Installer Configuration

  7. The Sub-component Installation screen should be displayed. This is one of the noticeable changes from version 7 to version 8 of ColdFusion. Hovering your mouse over each sub-component will describe in more detail what each sub-component does. If you plan to integrate .NET (especially with WebServices) or carry out Flex development then make sure that the “.NET Integration Services” and “LiveCycle Data Services” items are checked. For simplicities sake, check everything and Click “Next”.

    7. Sub-component Installation

  8. The Select Installation Directory screen should be displayed. The default directory for a Serverconfiguration will be “C:\ColdFusion8″ on a Windows machine. Click “Next” to continue.

    8. Select Installation Directory

  9. As you have chosen to install LiveCycle Data Services, you will need to agree to a further Licence Agreement screen. Click “Next”.

    9. Licence Agreement (LiveCycle Data Services)

  10. The Adobe Livecycle Data Services ES Installation screen is displayed. You will need to enter a serial number into this screen for production environments. Since I am going to assume a development environment, simply click “Next”.

    10. Adobe Livecycle Data Services ES Installation

  11. The Configure Web Servers / Websites screen should be displayed. This is the point where we want to connect ColdFusion with Apache. By default “Configure web server connector for ColdFusion” is checked. We need to add Apache so Click “Add”.

    11. Configure Web Servers / Websites

    1. The Add Web Server Configuration screen is displayed, choose Apache from the drop-down.
    2. Add the relevant Apache directory paths, e.g.:

      11-2. Add Web Server Configuration (Directory Paths)

      1. The Configuration Directory C:\Program Files\Apache Software Foundation\Apache2.2\conf
      2. The Server Binary Directory C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe
  12. The Review Configured Web Server screen is then displayed. If all the settings are correct, click “Next”.

    12. Review Configured Web Server

  13. The Choose Adobe ColdFusion 8 Administrator Location screen should be displayed. Since we are using Apache for our web server then the default Directory should be pointing to C:\Program Files\Apache Software Foundation\Apache2.2\htdocs. You can alternatively point this to C:\WebRoot or wherever you have set up your web project files. Select “Next”.

    13. Choose Adobe ColdFusion 8 Administrator Location

  14. The Adminstrator Password screen is then displayed, prompting for a password. Enter one, remember it (!!) and click “Next”.

    14. Adminstrator Password

  15. The Enable RDS & Password screen is then displayed. If you want to use this, check the box and provide an additional password. Don’t use RDS in a production environment. Click “Next”.

    15. Enable RDS & Password

  16. The Pre-Installation Summary screen is then displayed, detailing your configuration. This is your last chance to go back and make changes. If everything is OK, click “Install”.

    16. Pre-Installation Summary

  17. The Installing Adobe ColdFusion 8 screen is then displayed, showing a host of marketing messages.

    17. Installing Adobe ColdFusion 8

  18. The Please Wait screen is displayed, and be prepared to wait!

    18. Please Wait

  19. The Installation Complete screen is finally displayed and indeed the installation is complete. Now for the configuration! Click “Done”.

    19. Installation Complete

  20. Configuration and Settings Migration Wizard. Open up a browser and enter the url http://localhost/CFIDE/administrator/index.cfm to begin the ColdFusion 8 Configuration and Settings Migration Wizard. Enter your password and Click “Login”.

    20. Configuration and Settings Migration Wizard

  21. ColdFusion will now begin Configuring Server, which could take any number of minutes to complete.

    21. Configuring Server

  22. Once the Configuration Complete is displayed, you can login to the ColdFusion Administrator and start working, or playing, with the new interface, settings and Server Monitor.

    22. Configuration Complete

So, that only 22 steps! That may be the longest installation process you may go through, but the power now at your finger tips to produce hugely interactive websites is a compelling reason why to choose this version of ColdFusion, or indeed ColdFusion over other products.