Why IIF() Should be Avoided

I was recently reviewing some code from one of my client projects and saw that the previous developer had liked to use IIF() functions to handle the conditional switching of things like button labels. I idly quipped on Twitter that Every time you execute IIF() an angel loses its wings. A few minutes later a request for some explanation came in on Facebook: Why's that? I like IIF(). Here is why you should avoid IIF().

 


Utility Function: ImageBlurMore()

OK, so up until now you probably can guess that the functionality I'm working on has something to do with drawing or moving a shape since I've posted math rounding functions and functions dealing with geometric positioning. Lets throw you a curve-ball: I also need the following function. What happens when ImageBlur(image, 10) just isn't enough? Well you're going to need to blur the image more!

 

Utility Functions: Geometry Functions

Today we've got a double header of functions dealing with Geometry. As I said in my last post, I've been spurred into action by a user's question, and in order to solve his problem, I'm going to need to be able to calculate some relatively simple geometry. Click "more" to see how to convert Degrees to Radians and how to calculate the position of a point based on a starting location, angle, and distance.

 

Utility Function: RoundToClosest()

Its been a while! I got an email from a reader who wanted some help with a bit of image manipulation that has roused me back into CF coding! The particular bit of functionality he wants is rather complex, and so its been forcing me to make a bunch of utility functions to piece it together. First thing I ran into: rounding a number in CF is a little tricky. If you want to round to 2 decimal places, you should multiply the number by 100, call Round() and then divide by 100 again. What a waste. Luckily a little trickery with NumberFormat() can get us what we want.

 

How Do You Do This with ColdFusion 9 ORM ?

OK, so I've been working through build a new blog platform using the new ColdFusion 9 ORM setup, and I'm really impressed with how much of the basics it handles for you, but I'm starting to get into stuff thats more than just a simple CRUD action, and I'm finding that I've no idea how to make the ORM or HQL get me the results I need. Perhaps you can help me figure out what I need to do.

 

Weird ColdFusion 9 ORM Error

I'm trying to get a feel for the new ColdFusion 9 ORM setup, and I ran into an error message that I'd not seen before stating that "[Macromedia][SQLServer JDBC Driver][SQLServer]'FK3498A0CE621DF1' is not a constraint." This isn't too daunting, since I'm used to weird SQL errors, but when I refreshed the error I got back "[Macromedia][SQLServer JDBC Driver][SQLServer]Cannot find the object "post" because it does not exist or you do not have permissions." instead.Take a look at the particulars, and see if you can help me out.

 

More Entries

Jon in Chicago, July 2008

I'm Jon Hartmann and I'm a C# .Net developer by day, a ColdFusion guru by night, and all around Javascript fanatic. Stay right here to read my technical posts as I grapple with mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web. Learn more about me.

Post a job. Find one. authenticjobs.com

Interested in becoming a sponsor? Contact me.