ColdFusion Software Development Company ColdFusion Software Development Company

ColdFusion Array

Array is an essential tool in any programming language, which makes its implementation crucial for the programming language to be successful. In order to meet their goal of making simple scripting language for rapid and easy web development, Adobe made ColdFusion arrays simple for people who are lacking the proper training and programming experience.

First of all, ColdFusion arrays are not restrained to contain objects of any particular data type; arrays can contain objects of any type as well as other arrays. As a consequence, ColdFusion arrays do not possess “proper” multi-dimensional array structures. However, in order to achieve the functionality of the latter, the developer could create the structure by storing arrays inside the primary array. In fact, ColdFusion syntax supports multi-dimensional array indexing. On the contrary with the majority of widely used programming languages, ColdFusion array indexing starts with one versus conventional index zero. These features make the developer able to produce results with little or no understanding of how arrays are organized on the low level or without knowing common programming concepts .

Second, Adobe created the list of functions allowing a developer to manipulate ColdFusion arrays effortlessly. For example, functions like arrayToList() and listToArray() help user to transform array of strings into the single list string, and vice versa. While dramatically simplifying the development, such functions are not present in some programing languages. Furthermore, Adobe provides developers with helpful search functions, such as arrayContains(), arrayContainsNoCase(), arrayFind(), etc.  These functions help to search for different elements and their behavior is rather intuitive. However, all those functions could be reduced into the single arraySearch().  On one hand, this would make language less cluttered with functions but on the other hand it can confuse the new user and make an existing code less comprehensible.

With this being said, some Adobe’s solutions regarding arrays have hidden waterstones, which could cause the developers, especially inexperienced ones, to cause unpredictable errors. For example, the function arrayNew(), as the name suggests, would create an empty array with number of dimensions, between 1 and 3, passed as a parameter. As it was mentioned before, multidimensional arrays in ColdFusion consist of arrays made out of other arrays, therefore there is no need in this parameter, since created array will be absolutely empty. This can be confirmed by creating two arrays with different parameters and comparing with the method equals. The result will be positive. However, some invisible difference actually exists. It can be discovered by using method isArray(). This would check if object passed as the first parameter is array. The second parameter, which is optional, is number of dimensions array should have. If array matches the number of dimensions passed as the second parameter, then it will return true. This function can distinguish the number of dimensions, created by the arrayNew, thought it should not, according to the results of equals function. This could cause developers to produce different results, depending on their usage of this fact.

Overall, Adobe did a great job in implementing of ColdFusion arrays, so that it would be easy to use, however there are noticeable issues in its design. Some of those issues could be caused by their attempt to keep coldfusion backward compatible. This also can be noticed in their change, adding localeSensitive attribute  for the function arraySort(), in ColdFusion 10. Needless to mention that some of the ColdFusion functions that are designated for search have numerous bugs.

HAVE A QUESTION?

We would love to help.
Give us a call:

(718) 793-2828

Get a free project estimate:

Recent Comments
    Archives