Photo from Chile

ValidateThis! - Object Oriented Validations Demo Now Online

I have put together a demo of my validations framework for ColdFusion that I have been working on for the past several weeks. It's available here. The demo shows how the framework can take a simple xml file, which describes the business rules for an object, and generate client-side and server-side validations on the fly. It is a proof-of-concept, running in an environment identical to that which would be used in a real application. It is a simple, one-page example, but is utilizing Coldspring and Transfer behind the scenes.

From the demo page one can view the xml file that is being used to drive all of the validations. The schema for this file is still a work in progress, but it provides some insight into how one would implement the framework. Note that the schema itself is somewhat irrelevant, as the framework is designed to accomodate any schema, as long as it contains the expected metadata. Also, as a result of a conversation I had with Matt "I hate xml" Quackenbush, I have added the ability to define validations using ColdFusion code inside either your business object or another object injected into your business object. This is not something that I'd probably use, but I was led to believe that there are those out there who would appreciate not having to write an xml file to define their validations.

[More]

ValidateThis! - An Object Oriented Approach to Validations

I have written in the past about the approach I take to building an object oriented model layer for my ColdFusion applications. For the most part I was happy with the way I designed things and the code that I wrote. There was one area, however, that I was never really that pleased with; validations.

So I spent the past several weeks working on a whole new approach to doing validations, and I am now ready to share it with anyone who is interested. Because I intend for this to become a standard tool in my development toolset, I am going to refer to it as a Validation Framework. I'm not sure if that is an appropriate use of the term, but it's my code and my blog, so that's what I'm going to call it.

I had the following goals for my validation framework:

[More]

jQuery Auto-Filtering Table

I've been using jQuery for about a year now and I must admit that pretty much any JavaScript that I wrote prior to that looks ugly to me now. I know I'm nowhere near the first person to say this, but if you write JavaScript and you aren't using jQuery, you should check it out. Now.

Anyway, I wanted to show you how easy it is to do something cool with jQuery. The next thing I'll admit is that much of what I'm doing with jQuery involves using existing plugins written by other, more seasoned JavaScripters than me. But enough talk, here's the table:

[More]

You Cannot Use ColdFusion's Internal Java Class Method Names Either

We all know that you cannot create a method in a cfc that has the same name as a built-in ColdFusion function. For example, this:


    <cffunction name="DateFormat" access="Public" returntype="any">
        <cfargument name="aDate" type="any" required="true" />
        <cfreturn DateFormat(arguments.aDate) />
    </cffunction>

Throws this error:

But what I didn't know was that this:


    <cffunction name="EvaluateCondition" access="Public" returntype="any">
        <cfargument name="Condition" type="any" required="true" />
        <cfreturn Evaluate(arguments.Condition) />
    </cffunction>

Would throw this error:

It appears as if EvaluateCondition is a method of the coldfusion.runtime.CFPage internal java class, and I guess that's what's upsetting it.

File this under the "You Learn Something New Every Day" category, or under the "Bob Learns Something New Every Day" category if you already knew it ;-)

OT: I Drink Your Milkshake

First off, I apologize for the OT post. I really do try to limit these, and hopefully putting OT in the title of my post means that most uninterested people won't even be bothered by it.

Anyway, here's the story. I don't get much of a chance to watch movies, what with being a part-time stay at home father to two boys under the age of 4, and a part-time CF developer trying to keep on top of things and learn OO design and development. I've recently started a new exercise regimen that has me riding a stationary bike in my basement for an hour every other day, and while I ride the bike I usually get a chance to watch half of a movie. That is why I was finally able to view There Will be Blood the other night.

Loved it, which is usually the case for me with P. T. Anderson movies.

By some strange coincidence I was up late last Saturday night, reading blog posts and not really watching what was on the TV, when a skit came on Saturday Night Live that caught my eye. Now I'm old enough to remember when SNL was really, really funny, and also when it became really, really not funny, at which point I pretty much stopped watching. So I really have no idea whether the current cast of SNL does a good job or not, but I had assumed the latter. So I was amazed as I watched this skit, which I found to be one of the funniest things I've seen in years. It was a spoof of There Will Be Blood, with a touch of No Country for Old Men, and even Juno thrown in. I was laughing out loud. I laughed so much that I had to see it again, so I googled it and found a link to it.

So, if you've seen There Will Be Blood, and enjoyed it, and haven't seen the related SNL sketch, see below. I'm pretty sure you'll be entertained.

Strange ColdFusion Error Object

Today I came across a very strange ColdFusion error object. We've all seen the standard CF Error object when doing a try/catch/dump. It can be generated and viewed quite easily using a few lines of code such as this:


<cftry>
    <cfset myVar = UndefinedVar />
    <cfcatch type="any">
        <cfdump var="#cfcatch#" />
    </cfcatch>
</cftry>

That yields the following dump:

The exception being thrown is a coldfusion.runtime.UndefinedVariableException. Notice the Type key in the above struct. It's a string. We've all seen dumps like that many times. But, if I run this:


<cftry>
    <cfset str = StructNew() />
    <cfset ArrayAppend(str,"Test") />
    <cfcatch type="any">
        <cfdump var="#cfcatch#" />
    </cfcatch>
</cftry>

[More]

Some Benefits of Unit Testing

I must start by saying that, as much as I like option groups, I love Unit Testing. I had written previously that I Like Unit Testing, but that brief infatuation has blossomed into a full blown love affair. I have two people/groups to thank for that, Paul Marcotte and the MXUnit Team, who produce an excellent suite of unit testing tools for ColdFusion.

I met with Paul in the Toronto airport a couple of weeks ago during a brief stopover (his, not mine) and he walked me through his current methodology for unit testing. He really cleared up some areas of confusion for me, and essentially handed over a set of practices that makes everything oh so easy. He's been blogging about his technique in a series that I heartily recommend.

And what can I say about MXUnit that hasn't already been said? It totally rocks! The Eclipse Plugin is da bomb! If you haven't checked it out, do so. Now. 'Nuff said.

So when do I get to hear about "Some Benefits of Unit Testing", you may be asking? Read on.

[More]

More Entries