Wednesday, July 21, 2010

Why null sucks. Reason 641.

A little bit of sql code here:


SET @test = NULL

IF (@test <> '7/31/2010')
SELECT '@test is not equal to 7/31/2010'
ELSE SELECT '@test is equal to 7/31/2010'

Amazing. We've just figured out that a null date is equal to 7/31/2010. Who would have guessed? The reason this is problematic is that there is no way in the current implementations of sql to express n-value logic results. Comparing null to 7/31/2010 should result in null or unknown (or something else depending how many values are in your logic table). The If construct in SQL is boolean, but the test I showed above is not.

Sunday, March 28, 2010

FW/1 Notes - fw.populate()

If you've followed my blog for any period of time, you'll know that I have not been a big supporter of the various CF frameworks floating around. Until now. I've been working off and on for the past few months with FW/1 and I'm sold. Finally there is a lightweight framework that just seems to make sense to me. It's what is known as a framework by convention instead of configuration and it's very lightweight. In fact the entire framework is contained in a single cfc. Sean Corfield, the author, has done a remarkable job of keeping true to the framework's mission of remaining lightweight and protecting it from feature bloat.

I have to admit that in the past, I just couldn't commit enough brain cycles to get my head around some of the other frameworks I've tried fast enough that I wouldn't just drop it out of boredom.

FW/1 lets you get to that magical lightbulb effect where things just start working quickly. Once you get over that initial hump, then you can dig into the more esoteric pieces when you need them.

As I continue working with it I'll make a few notes here, mainly for my own reference, but also to record some of the issues I've stumbled with as I learn.

This is a handy little function included in the framework that allows you to quickly populate a bean. Most often I use it to fill out a bean that is being populated from a form that was just submitted so that I can work with it. It saves you the trouble of calling all of your setter functions manually.

With the introduction of cf9, we now have implicit getter and setter functions for components driven by the property keyword or cfproperty tag depending on you cfc style (tag/script). One gotcha for me is that if you utilize those implicit accessors, you have to provide the function with a list of the properties you want populated. If you forget to supply that list, the function only populates attributes that you have written explicit setters for. Also if you have an odd case where a setter takes more than one argument (to support a derived property or do some unusual logic in the getter) it will probably just skip over that property.