Friday, January 25, 2008

Continued CF Whining

At this point I'm simply going to have to assume that all CF data is string data, and deliberately coerce it into behaving like numeric data as needed:

I have a query, and the field "storeId" is defined in the DB as being an integer. I have a method, setStoreId(), which has an argument, defined as being an integer. If I do obj.setStoreId(query.storeId), an expression exception is thrown, because query.storeId is not an integer.


And if I bludgeon that into submission, then later when I do getStoreId(), which is defined as returning an integer, I get another expression exception, because the value it's returning isn't an integer. Even though its value is the number 110.

1 comment:

Anonymous said...

As far as I've ever known, Coldfusion has no idea of an integer, but I've never dealt with the CFC's. I got the impression those were a bait-and-switch - the code looks more like it isn't a toy language, but you still have the same problems without that shoot-from-the-hip flexibility that you get from a toy language.
10/4 is going to be 2.5, and never 2 unless you also do Int() on the answer, but it's really just floor() in disguise. It's not anything like a cast. Everything is a scalar - even when it's a number, you're still looking at it through the scalar lens.

My advice for working well with CF is to get dumber. You'll still have the same problems, but if you find a way to compartmentalize the things you know about computer science that tell you there is no reason a language should have these problems, and just work around it, it will be easier on you. Instead of drawing up plans for Falling Waters, it's more like drawing a map of a scooby doo haunted house without falling down a trap door or a sliding staircase.

"We just came out of the trash compactor . . . shouldn't we be wet?"
"It's not that kind of movie, kid"