ColdFusion is NOT dead, it's just NOT marketed well!

Goog Feed, ColdFusion    Comments (14)


"ColdFusion is pretty much a dying language," said the customer service rep for a very popular hosting company, which I will name later.

Alright, enough of this! I know this has been a touchy point for ColdFusion developers for years, from the days of Allaire, to the purchase by Macromedia in 2001 which everyone thought would be CF's demise, to the purchase by Adobe in 2005 which we hoped would push CF to new heights in the coding world, but hasn't really came to pass as of yet.

In thinking this through, I have come up with a theory as to why CF after 10 plus years is still, a "dying" language...

So how did this come to pass?

A buddy of mine here at work recently called GoDaddy.com in regards to their hosting package, which currently offers CFMX7. He asked the rep if they had any plans in the works to upgrade to CF8. His response was "hold on a minute, let me check on that for you...," a couple minutes later he comes back on the line... "I just talked to our developers and they say that ColdFusion is 'pretty much a dying language' and we have no plans to upgrade at this time."

This coming from one of the biggest hosting providers in the world doesn't sit well with making me feel any better about the future of CF.

So, here is my theory. I think CF is awesome, I think it offers so much to the developer, it is easy to use and program in, it is very robust, BUT it's one drawback, the PRICE TAG!

Listed at $7,499.00 by Adobe for the Enterprise Edition of CF doesn't exactly make CF an attractive option for going the route of CF. Why would ANY company want to pay $7,500.00 bucks just to set the stage for a developer to write and deploy code, when there are FREE alternatives, namely, PHP, JAVA, ASP, etc...

This is our livelihood, CF is how we get paid, you would think that Adobe would make CF a more attractive alternative to it's competing languages. If Adobe make purchasing CF something that was NOT a financial burden, then more companies would use it. If more companies used CF, more CF jobs would be created. When more CF jobs are created, our futures become more secure, pay goes up and Adobe shines.

Maybe my perception is off, but this is just my perception of this whole situation. What do you think?

Comparing the Match Percentage of Two Strings

Goog Feed, General, ColdFusion    Comments (4)


Today at work, my boss asked me to check into "Fuzzy Match" capabilities in ColdFusion for a project we're working on here at work. Basically we want to compare two strings and find out what is the percentage of match between the two. For example does string one match string two with 70% accuracy or better?

So after a couple Google searches I came upon a partial solution. All signs pointed to the fact that I would have to use the Levenshtein distance formula which calculates the number of replacements, insertions or deletions necessary to match string one exactly up to string two.

I happened across a ColdFusion UDF written by Nicholas Zograpos which uses the Levenshtein formula to do this computation and passes back the number of characters needed to change string one into string two. You can find the UDF here.

I put this UDF at the top of my CFC.

<cfscript>
/**
* Computes the Levenshtein distance between two strings.
*
* @param s First string. (Required)
* @param t Second string. (Required)
* @return Returns a number.
* @author Nicholas Zographos (nicholas@nezen.net)
* @version 1, March 15, 2004
*/
function levDistance(s,t) {
var d = ArrayNew(2);
var i = 1;
var j = 1;
var s_i = "A";
var t_j = "A";
var cost = 0;

var n = len(s)+1;
var m = len(t)+1;

d[n][m]=0;

if (n is 1) {
return m;
}

if (m is 1) {
return n;
}

for (i = 1; i lte n; i=i+1) {
d[i][1] = i-1;
}

for (j = 1; j lte m; j=j+1) {
d[1][j] = j-1;
}

for (i = 2; i lte n; i=i+1) {
s_i = Mid(s,i-1,1);

for (j = 2; j lte m; j=j+1) {
t_j = Mid(t,j-1,1);

if (s_i is t_j) {
cost = 0;
}
else {
cost = 1;
}
d[i][j] = min(d[i-1][j]+1, d[i][j-1]+1);
d[i][j] = min(d[i][j], d[i-1][j-1] + cost);
}
}

return d[n][m];
}
</cfscript>

Next, I created a function of my own inside of my CFC which calls the levDistance function passing in two strings, it then divides the result by the length of the string we want to match against (stringTwo) and multiplies by 100 which gives the percentage of error between the two strings in numeric format. Finally I compare the error percentage with my threshold or my max error percentage I am willing to allow, passing the user back a true/false based on the result.

You'll find my function below.

<cffunction name="stringCompare" access="public" returnType="boolean" output="false">
<cfargument type="any" name="stringOne" default="" required="yes">
<cfargument type="any" name="stringTwo" default="" required="yes">

<cfset var result = true />
<cfset var threshold = 30 /><!---This means that we are only allowing for a 30% error rate, 70% match in essence.--->
<cfset var stringCompare = levDistance(trim(arguments.stringOne),trim(arguments.stringTwo))/len(trim(arguments.stringTwo))*100 />

<!---Comparing the result.--->
<cfif stringCompare GT threshold>
<cfset result = false />
</cfif>

<cfreturn result>
</cffunction>

Finally, one last bit of code. How to call the function from the view.

<cfset st1 = "How are you doing?" />
<cfset st2 = "How are ya doing?" />

#myObj.stringCompare(stringOne=st1,stringTwo=st2)#

You can play with the percentage numbers as needed to fit your situation. This really helped me in a problem I faced, hopefully it will do the same for you!

CFUnited: My Recap

Goog Feed, General, ColdFusion, CFUnited 2008, SQL    Comments (0)


CFUnited 2008 was a great experience for me personally, I presented as a speaker for the first time which was a great experience and challenge, as well as learned a great deal of things that I would like to put into practice in my own development environment.

I wanted to put a quick post out there to go over some of the highlights that I was able to take away learning wise for others to see as well as a constant reminder to myself. So, what did I personally learn?

  • In his own words, Ray Camden will be using tables for layout until someone stops him... Should've come to my session Ray!
  • I want to start using CFToolTip more for my end-users benefit.
  • There is a cool Event Validator at RiaForge that Mark Drew referenced, I would like to check into that when I get the time.
  • From Hal Helms session, leave functions open for extention, closed for changes. Keeping things simple
  • Just because MVC is used, doesn't mean I'm doing OO. I can still be doing procedural code in an MVC format.
  • Get book called Design Patterns by Gang of Four
  • Find the things that are constantly changing in my applications and encapsulate them.
  • Good OO is all about abstraction.
  • Pass objects to be persisted.
  • From Chris Scott's session, keep ColdSpring simple - getBeans/setBeans
  • Increase the JVM default on the CF Server.
  • Increase the minimum memory on the CF Server.
  • Turn on trusted cache in production.
  • Cache queries used often in applications.
  • Read the CF8 performance brief.
  • Use SQL Server performance monitoring tools to profile, trace, look at execution plans and their costs, run database reports to see which queries are putting loads on the server.
  • If session is not available, reject the form submission, because it means they didn't come from your form.
  • From Joe's advanced Model-Glue session... you can use the include tags to include entire applications into your Model-Glue app.
  • Prefix event handlers.
  • Controllers should be as thin as possible.
  • Use views for common joins, filtering, etc... when dealing with larger queries.
  • Index all fields searched on in my SQL tables for fast searching and less load on the database. A good example of this is looking for pizza in the phone book, but searching every page of the book from A-Z. With indexing you don't need to search from A-Z simply jump to 'Pizza'.
  • SQL views can be about 75% faster than CF for complex queries.
  • Stored procedures can be about 90% faster than CF.
  • Use cfQueryParams for security as well as not making the SQL Server re-write execution plans everytime a query is run.
  • Be careful about how you index your tables, you could do more damage than good if it's not done right.

That was my quick recap of what I learned. Overall the venue was great, I loved the fact that the conference was in downtown DC instead of Bethesda, the hotel was awesome and close to the conference. Another great job by the CFUnited team. I hope to return in 2009.

CFUnited: Off To Washington D.C.

Goog Feed, CSS, General, ColdFusion, Photography, CFUnited 2008    Comments (2)


Well, tomorrow morning bright an early I leave for Washington D.C. for a ColdFusion conference at which I'll be speaking on "The Power of CSS". I am excited and nervous all at the same time. Wondering if my presentation will be valuable, sufficient and timely, but excited about things I may learn and all that goes with experience of taking a trip.

I'll be blogging daily about the conference and the trip, posting pictures and musings about the things I experience on a daily basis while I am there.

Today, my wife LeeAnn has been running about trying to get some last minute things together before I leave. I'm going to miss LeeAnn and the kids while I'm gone, but it will work out for good. The kids have already been asking if I was going to bring them back t-shirts like I did last time.

I picked up a new lens for my camera while I am there, which I will blog about shortly, it's an Nikon 18-200mm VR Nikkor lens which gives me great range when I am out exploring D.C. so I am looking forward to getting some great shots with it.

Well, here goes nothin'. Stay tuned for more...

SQL Dynamic Date Range

Goog Feed, General, ColdFusion, SQL    Comments (0)


I work for a school district here in Texas and today an issue arose. We needed to run a nightly SQL job which pulls students from our Student Information System and dumps them into some tables we use for a local application. Problem is while we have about 22,000 active students our total student table has over 55,000 records in it, some from prior years.

The initial reaction was to hard-code the school year start and end dates into the system, but then if our DBA leaves, or we forget what kind of lame hack we put in place we have problems next school year.

I had done this previously in ColdFusion, but today I decided to do a SQL version of it. It will take the current day and decides what the current school year start and end dates are based on the current day, so we're always pulling current data only no matter what year it may be.

DECLARE @startDate datetime
DECLARE @endDate datetime

SET @startDate = cast('7/1/' + cast(datePart("yyyy",getDate()) AS varchar) AS datetime)
SET @endDate = cast('6/30/' + cast(datePart("yyyy",getDate()) AS varchar) AS datetime)

SET @startDate = CASE WHEN cast(@startDate AS datetime) > getDate() THEN cast(dateAdd("yyyy",-1,@startDate) AS datetime) ELSE cast(@startDate AS datetime) END
SET @endDate = CASE WHEN cast(@endDate AS datetime) < getDate() THEN cast(dateAdd("yyyy",1,@endDate) AS datetime) ELSE cast(@endDate AS datetime) END

SELECT @startDate AS startDate, @endDate AS endDate

The end result is 7/1/2007 as the startDate and 6/30/2008 for the endDate. It works perfect for us, and I hope it works for you.

More Entries