From: Avdi Grimm Date: 2008-08-16T05:32:04+09:00 Subject: Re: BDD and TDD - What are they for? On Fri, Aug 15, 2008 at 4:10 PM, Clinton D. Judy wrote: > BDD looks like a way to make it easy for non-programmers to do > programming, but not having people keep several functions in mind at any > one time. And it also does TDD? Am I close? BDD is simply an altered vocabulary for TDD. Vocabulary is important; it effects how you think about a problem and how you decompose it. For a lot of people, including myself, thinking about things in terms of specifications of behavior rather than in terms of "how do I test this method" leads to better-designed code. What's the deal? Like pair programming, BDD/TDD is one of those things you have to try to get. If you can, find someone who is a pro at it and do some TDD coding together. At some point it will "click". For me it was when I spent several weeks coding C++ by myself with nothing but the spec for a communications protocol, and the very first time we integrated my library into the main product it worked out of the box. That kind of integration experience was unheard-of where I used to work. I was hooked from then on, and I've never gone back. Most of the TDDers I know have their own similar conversion story. I find that when I'm writing code test/spec-first, I don't have to worry about debugging. The code is usually right the first time, and when it isn't the problem is obvious. It also forces me to write code that is properly decoupled and obeys the single responsibility principle, making changes much easier. It sounds like you are doing most of your coding alone, on projects that you can pretty much hold in your head at the one time, and on which you can manually test without much trouble. When you start to work on projects that haved tens or hundreds of thousands of lines of code, have had many developers, some of whom are long gone, and which could take days to manually test, the benefits of complete test/spec coverage become impossible to ignore. And the only way to guarantee complete coverage is to write the tests first. But really, the only way to discover the joys of BDD/TDD is to do it for a while. -- Avdi Home: http://avdi.org Developer Blog: http://avdi.org/devblog/ Twitter: http://twitter.com/avdi Journal: http://avdi.livejournal.com