cf.objective() 2007 : Test Driven Development
admin | May 6th, 2007 | conferencesThis session was with Paul Kenney who is now working with Adobe in their Hosted Services Group. He is also the creator of cfcUnit, so I was eager to see what the framework could do compared to our experience with cfUnit.
Paul basically described test driven development (TDD) as the incremental process of designing your unit test cases prior to writing your code. He was explicit in saying however that you should develop test cases and their corresponding code one at a time. The goal was not to spend the entire time developing a test suite that didn’t have the ability to run. He said TDD was the process of implementing the most basic functionality needed (the provided specs in most cases) to satisfy the Test (I usually call this a test method). Once you’ve completed your code base and test cases, TDD requires that you participate heavily in refactoring to seek out the following issues:
- Duplication of responsibility
- Unclear Intent (classes with low cohesion)
- Code Smell (=Intuition about your code)
- Adding relevant comments
- Indentifying if something should be a data class (which I think is what he’s calling a VO)
- Code Duplication
- Inappropriate Intimacy
- Large Classes (possibly low in terms of cohesion in which size is a potential indicator)
- Lazy Class (not sure about this one)
- Long Method (again another low cohesion issue)
- Switch Statements (possible indicator for seperation of responsibilities)
- Shotgun Surgery (code changes propagated across multiple classes, possible identification of tight coupling)
I like some of the terms he used because they’re quirky, but I didn’t see a lot of formalization in the presentation.
Paul then showed us the basics of how cfcUnit works. He has a nice test runner compared to cfUnit, but with the CFEclipse integration now, I don’t see that as a huge advantage. I also noticed that on a failure, only the failure message, default or custom, is delivered in his test runner, but no line number is available. This kinda sucks and I’m not sure cfUnit has that functionality, but it’d be nice to see. Overall, I didn’t really see a reason to switch over to cfcUnit from cfUnit at work. Pauls says now that he’s getting a lot of community support, he is going to start putting together a bunch of new resources for the API, improving support, and begin looking into what upgrades he can give the framework. I’d definitely like to see more in terms of the hacked form of annotations I’m seeing used now at the conference (idea of added extra attributes to a tag, so getMetaData() can be used during introspection on the tags).
