While in Romania, facilitating the Bucharest Coderetreat, I had the opportunity to teach a Test-Driven Development class with J.B. Rainsberger. We've talked about teaching together for many years, and I'm honored to have finally had the opportunity. If you have watched the videos that I did last summer with J.B., you'll know that he has an amazing amount of experience and insight into the development process. He has an ongoing blog called 'The Code Whisperer,' which has consistently thought-provoking content on design, testing and other coding techniques. If you haven't watched them, I urge you to look through the archives for them, as his thoughts on test-driven development are enlightening.
Whenever I have time with J.B., I do my best to get some videos recorded with him covering whatever might be of interest to us at the time. This past opportunity was a goldmine, as, not only did I get 3 videos, but we also used ustream to live-stream the interviews. While I was copying onto my computer, J.B. was kind enough to do impromptu Q&A sessions with the people viewing.
This is the first of those video interviews, focusing on the often-mentioned, more-often-misunderstood topic of 'Primitive Obsession' in design.
Enjoy! As always, constructive feedback is welcomed in the comments. If you are so inclined, please write a blog post with your thoughts.
Coming next week: Gary Bernhardt discusses some of the differences between the ruby and python cultures.
JB Rainsberger - Primitive Obsession from Corey Haines on Vimeo.


Great interview as usual! Full response on my blog at http://silkandspinach.net/2010/03/03/primitive-obsession-or-open-secret/.
ReplyDeleteGreat interview. I was a little confused when you brought up "the Type is not the Class" concept. It sounded almost like a contradiction of J. B.'s "Whole Value" concept. It seems to me that treating a string as a list of email addresses is not a good practice and that string really *should* be wrapped in a new class. Did I hear that wrong?
ReplyDeleteJason,
ReplyDeleteGood point.
The concept is that the initializing class is just that, an initializing class. The type could be considered as the set of interactions that are allowed, how the other parts of the code deal with it.
"Wrapping in a new class" is one technique for providing new behaviors to an existing object. Other languages, though, provide alternate mechanisms, such as mixins and prototypes.
So, in this case, you aren't treating a 'string' as a list of email addresses, you are treating the object as a list of email addresses. The object's available behaviors can be shifted at runtime.
In class-oriented languages, such as Java and C#, you have a much tighter coupling between the concept of 'class' and 'type' due to a limited set of object evolution mechanisms.