(This is a not a question to survey the merits of TDD. There are other places for such discussions. Thanks in advance.)
I've been experiencing too many developers who are novice at the technique, who are also reporting dissatisfaction with, test driven development and NUnit.
I hear negative comments like:
"I don't like NUnit. I tried it a year ago, but I forgot how to use it. Let's just use this Windows Form app I just wrote ad-hoc as a test harness instead. Test code is throwaway code anyway, what's the difference? Anyway, my way worked well enough in the past."
"I have reservations about TDD. On our last project (which was my first and only project experience with TDD, by the way), we don't even know what the design is any more."
"More code-comments are BAD? Are you crazy? I really have some work to do if you don't mind." (From the old school of more comments are better comments, and you can never have too many comments.)
When a novice complains that TDD supposedly 'did not work' to their satisfaction on their first-ever project using TDD, is it really TDD that has failed them, or is it the developer himself whose skills are not yet sufficient to get good results?
And how can I communicate that without them hating me for saying it?
The crux of the question is, what can be communicated diplomatically to developers to encourage them to take a more honest appraisal of their own nascent and insufficient capabilities with new development technologies, without endangering our important work relationships?
Typically, many developers are clearly not yet equipped with a working mastery of the many important elements of TDD to pull it off very well, when on their very first project.
For example, it is typical that complainers in the development community that I have talked to:
Have never even attempted to look at or remember the list of code smells.
Have never even attempted to study the catalog of refactorings, nor have they practiced any of them ever either in real projects or in toy projects for learning. For some people there there may be a lot more OOP to learn, in order to simply be able to do refactoring very well. There is far, far more to refactoring than just "rename method" and "rename variable" which appear as items on the Visual Studio 2005 Refactoring menu.
Have never even attempted to study or participate in real projects implemented using emergent design (via refactoring), versus doing a whole project using design in advance, versus a whole project writing the unit tests only after the code is written, and knowing the differences and tradeoffs and applicability between any of the them.
They all seem to have used NUnit, once, so whatever they did with it, it was TDD,by golly, they seem to think. The presence of NUnit or unit tests, simply does not imply TDD, but they don't understand enough yet to even know that.
These are smart people. Developers are smart people because that's the bar to entry to the entire occupation. You can't be in the occupation for too long otherwise. Of course they could understand it, if they applied themselves for a while to study these materials.
How can people honestly tell themselves a methodology is weak, when their sum of experience and knowledge is what's obviously far too weak to even be able to make an appraisal of a methodology or its results?
Yet they do... It's self-protective behavior, I believe. Or it's laziness. If you can't even name three refactorings from the catalog of Fowler's Refactoring book, or if you can't name several code smells, you are a rank novice at refactoring, and probably also the entire TDD methodology, and your so-called 1 or 2 project experience is evidently not enough.
What can I say to people or what materials can I direct people's attention to, to get them to do what it takes to learn much more about the skills that success with TDD depends crucially on, like:
- unit testing,
- refactoring,
- design patterns,
- OO design and analysis?
There are whole books on each of these topics, some very good. Maybe there are some easier-to-swallow learning techniques too? I can teach people by example, but my own time to give to them is limited, and furthermore, I am not yet a black-belt in all these techniques either.
Furthermore, they go together. They don't work very well without each other. Unit testing and refactoring go together like peanut butter and jelly. If you can't grep unit testing, then you surely won't have very good results at all with your refactoring!! (Ask me why if you don't know yet, I am happy to explain it to new people.)
It is also vital that whatever I do or say, that it does not backfire:
I must not alienate my colleagues from the TDD concepts; and moreover, I must not alienate my colleagues from me. I shall have to work with them every week for many more years to come.
It's particularly hard to not upset other long-time senior developers, who have already established themselves as being highly proficient in other facets of programming. They are rightfully proud of their past accomplishments, but their egos or their self-concept of mastery of all things in programming, can be almost insurmountable to deal with, without hurting their feelings. Some senior developers are unready to face up that they don't know some newer techniques that they should learn from someone else. Senior developers can be more accustomed and comfortable to being the experts in the room when it comes to programming, and sometimes they demand to be regarded as such, even when it's wholly unrealistic when it comes to TDD and associated techniques and technologies.
I am happy to report that one way I've had pretty decent success in turning around one of our resident "resisters" on writing structured automated unit tests, is by using pair programming with them, one on one. Pair programming gives trainees some real life examples and experience, I guess, along with the direct tutelage of a more experienced and knowledgeable practitioner.
But pair programming is not enough. There are many more refactorings, code smells, OOP concepts, and OOD&A concepts which they need to learn, and I can't teach all of them in a single project, not even close.