ColdFusion Helpers for Halo 2 Contest
For those of you who are CF’ers and are looking to get more structured access to the Halo RSS feed data, I’ve made available the CF source I used to do so during some of my development trials. There’s two files - feed.cfc, which is the CFC that handles the workload, and feed.cfm, which is an example of how to use the CFC. So why didn’t I use this in my project? Read on…
Note: This code was developed to test out an idea and was not designed with performance in mind. It comes as-is, with no warranty (smile).
I started off with fairly lofty feature goals. One of those features had me getting into an algorithm that had three nested “for” loops, and leveraged a minor degree of recursion. Bottom line - it was some ugly (though rather well performing) ActionScript. It seemed to me that I may not be using the right tool for the job. Indeed, if I could throw some XPath at the problem, I could eliminate the recursion and simplify the loops. Since CF offers great XML manipulation features (including XPath), I figured I’d go that direction.
I thought I might also be able to add some additional performance gains by leveraging remoting from my Flex app to the CFC for data calls. The idea was that I could have the server retrieve the XML feed and store it locally for processing until a refresh was requested from the application (every 15 minutes by default). At that point in time, I’d grab the latest RSS data. In the meantime, the Flex application would only be accessing small data chunks from that local XML file at a time (via a CFC object model), based on what the user wanted to see, and thanks to remoting, it would be a binary payload.
This approach would also allow me to be somewhat protected from the otherwise unpredictable feed availability. If the server was down, CF would catch the error and use the local file instead (not implemented in my example).
The trade off of course is that Flex itself has some rather nice XML facilities. The HTTPService class represents the XML data as a well structured DOM. Data-binding UI elements to XML data nodes makes display a walk in the park. Label function properties allow me to dynamically customize the way the node(s) display. If only I could get over this feature hump!
In the end, I dropped the feature, and went with another UI metaphor. Without the feature, it was much easier to stay inside Flex to accomplish my [now] fairly limited data processing. It also allowed me to hit the short, one-week deadline with other “nice to have” features. But I still have this dang CF code lying around (wink)! Please feel free to help yourself.