The Dopefly Tech Blog

« The Dopefly Tech Blog Main page

Fun with Functions and CFCs V - Method Copying / API Updates, Practical Uses

posted under category: ColdFusion on December 14, 2007 by Nathan

Here's something I did a few months ago. What happens when the names in your exposed API are too confusing? It's been published, now it's too late to take it back, and now millions of other developers (ok, a handful, if we're lucky) who depend on our object would cry foul if we changed it. What to do, what to do?

Well, why not just rename the method? Ok, rename is too strong a word. How about copying a pointer? Oh yeah, that's easy.

<cfset variables.getMethodWithStandardName = variables.getMethodWithFunnyName />
<cfset this.getMethodWithStandardName = this.getMethodWithFunnyName />

There we go, now you can go about using an updated API while leaving the old API in place and not breaking any backward compatibility!

Nathan is a software developer at The Boeing Company in Charleston, SC. He is essentially a big programming nerd. Really, you could say that makes him a nerd among nerds. Aside from making software for the web, he plays with tech toys and likes to think about programming's big picture while speaking at conferences and generally impressing people with massive nerdiness and straight-faced sarcastic humor. Nathan got his programming start writing batch files in DOS. It should go without saying, but these thought and opinions have nothing to do with Boeing in any way.
This blog is also available as an RSS 2.0 feed. Click your heels together and click here to contact Nathan.