An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

Entries for month: December 2009

Automated Testing with Selenium

December 30, 2009 ·

A few weeks ago, I blogged about a fix for running Selenium with ant on Snow Leopard and several people have asked me to blog about the basic setup for which that fix applies since it is of much broader interest to developers... Yes, good point! A bit of background first. I'm working on a large ColdBox project and one of the first things I did when I joined the project was to start creating some unit tests and integration tests. ColdBox has integration with MXUnit so you can fairly easily write unit tests for parts of your model and integration tests for your event handlers. Over time we've built a suite of over 100 MXUnit-based tests. If I had my way, we'd have a lot more by now but test-infecting your colleagues isn't always easy!

[Read more →]

Tags: coldfusion · tdd

Improving CFSCRIPT

December 29, 2009 ·

One of the new features in Adobe's ColdFusion 9 release that has excited a lot of developers is the broad range of enhancements to CFML's "other" language: CFSCRIPT. In the past, I've been very disparaging about CFSCRIPT and I've gone so far as to say in several public - and private - forums that I felt CFSCRIPT should be deprecated and no further effort spent on it. It was always a bit half-baked with weird restrictions and lots of important features missing. It was annoying to use, because you often had to switch back to CFML's tags to get things done. With increased use of CFCs, the restrictions in CFSCRIPT made it even more painful to use because you could not specify function arguments easily in CFSCRIPT - no types, no defaults - and you couldn't express a function's access or return type.

[Read more →]

Tags: cfml-advisory · coldfusion · adobe · railo

Quick ColdBox / i18n tip

December 21, 2009 ·

Today I needed to update a custom tag we use to display form fields in a ColdBox app to treat the labels as i18n resource keys. Normally in a view you can just call getResource(key) and get back the translated value based on the current locale. Simple. Part of what makes ColdBox great for international apps! However, you can't call getResource() inside a custom tag called from a view. You might think you can just do caller.getResource(key) but that fails with an exception that the variable controller is not defined. That's because your views run in the context of a CFC and the custom tag has its own context. I initially came up with a slightly complicated way to pass things to the custom tag but I ended up having to make getResource() public in ColdBox's FrameworkSuperType.cfc. Not ideal. It worked but it was clearly a hack. I complained to Luis about how hard this seemed to be and he sent me the following code snippet to use in a custom tag:
<cfset variables.controller = caller.controller />
...
... caller.getResource(key) ...
Remember that you're in the context of a CFC in your view? Well, getResource() is in the variables scope and it, in turn, references controller - which is in the variables scope of the view... or rather the context that the view is executed in. So by setting variables.controller in the custom tag, the call to caller.getResource() finds it and runs properly. It's still a bit of a hack in my opinion but it's slightly more elegant than what I was trying to do so thank you Luis. I'm posting it here so a) I can find it again in future and b) others may benefit from this.

Tags: coldbox · coldfusion

Selenium, ant and Snow Leopard

December 17, 2009 ·

With the arrival of my new 27" iMac, I'm now doing all my development on Snow Leopard and that caused a problem today with my automated Selenium tests... I use ant to drive Selenium to launch Firefox to run UI-based test suites. It's pretty slick and I'll blog about it soon. Unfortunately, on Snow Leopard, Selenium cannot launch Firefox from the command line (due to a security exception caused by a library mismatch it seems). Myself and Peter Bell have been looking for a workaround for this for a few days and even started looking at the alpha builds of Selenium 2.0 which claim to resolve this (but we couldn't figure out how to drive those builds from ant). Some Googling turned up Matt Patterson's blog post with a simple workaround. The root of the problem is the dynamic library load path in the environment and his workaround is simply to use a shell script wrapper that removes the environment! Then you can specify browser="*chrome path/to/selenium-firefox" with your shell script in the selenese ant task and you're off to the races.

Tags: tdd

Why CFML? Why not Java?

December 13, 2009 ·

David Tannersyn commented on my blog post about MFG.com taking three years to overhaul their web site. He's interested in a balanced argument as to why anyone would choose CFML over Java in this day and age. Here's David's comment, with my answers interspersed.
I spotted your comment on the Tech Crunch, MFG.com article (among many other CF advocates), found your blog, and had a look around.
The TechCrunch article received a lot of commentary from CFers, much of which bordered on fanboi-ism - which we as a community do tend to slip into because of our passion for CFML. Some of the comments were downright insulting (to TechCrunch and to MFG.com) which might be a whole bunch of fun but doesn't do our image much good when viewed from outside our community. Given some of the heat in the comments, I'm glad David still took the time to come here and ask questions - many folks reading those comments probably just wrote us off!

[Read more →]

Tags: coldfusion

Static is Evil

December 12, 2009 ·

This cropped up on the TDD mailing list and it made me smile so I wanted to share it along with some commentary. A fairly common request from folks in the CF community is for "static" methods (and data members) to be added to CFML. Folks look at Java, think it's a cool concept, and want it in CFML as well. I generally pop up and say it's a bad idea and that Java only has static because it doesn't have any concept of a global application scope (which CFML does, of course).

[Read more →]

Tags: coldfusion · architecture · tdd

cf.Objective() 2010 - Update on Submissions

December 10, 2009 ·

A few people have asked on Twitter and via email what is happening with submissions that have been sent in to Jim and myself. We're a bit behind. We hoped to have reviewed all the submissions last week and to have been notifying everyone this week about accepted and rejected sessions. Sorry! We're actually about two weeks behind (which is just as well for a few speakers that are still submitting their sessions!). We've had over a hundred submissions so far and we will only be able to accept about half of them. There are some fascinating topics being submitted - in addition to the great topics suggested by the Content Advisory Board for the first round of invited speakers. We've also had multiple submissions from a number of speakers (up to six submissions from a single person!) which helps us a lot because we have a fixed limit on the number of speakers we can accept (for budgetary reasons). We should be able to get through the reviews next week and then we'll be notifying speakers the week after (the holiday week). We're hoping to have a list of sessions posted by year end and a rough schedule posted the week after. Registration should be open next week for those who want to get cf.Objective() into this year's budget without waiting for a published schedule.

Tags: coldfusion · cfobjective