TDD is how I do it, not what I do 51
“Do not seek to follow in the footsteps of the men of old; seek what they sought.” ~Basho
That quote resonates with me. I happend across that a few days after co-teaching an “advanced TDD” course with Uncle Bob. One of the recurring themes during the week was that TDD is a “how” not a “what”. It’s important to remember that TDD is not the goal, the results of successfully applying TDD are.
What are those results?
- You could end up writing less code to accomplish the same thing
- You might write better code that is less-coupled and more maleable
- The code tends to be testable because, well, it IS tested
- The coverage of your tests will be such that making significant changes will not be too risky
- The number of defects should be quite low
- The tests serve as excellent exampls of how to use the various classes in your solution
- Less “just in case” code written, which typically doesn’t work in those cases that they targeted
Right now I do not know of a better way to accomplish all of these results more effectively than practicing TDD. Even so, this does not elevate TDD from a “how” to a “what.” TDD remains a technique to accomplish thigns I value. It is not a self-justifying practice. If someone asks me “why do we do it this way”, saying something like “we practice TDD” or “well you don’t understand TDD” is not a good answer.
We had an interesting result during that class. One group was practicing Bob’s three rules of TDD (paraphrased);- Write no production code without failing tests
- Write only enough test code so that it fails (not compiling is failing)
- Write only enough production code to get your tests to pass.
- S.O.L.I.D.
- F.I.R.S.T.
- Separation of Concerns (Square Law of Computation)
- Coupling/Cohesion
- Protected Variation
- ...
TDD is a means to an end but it is the end we care about. What is that end? Software that has few defects and is easy to change. Tests give us that. Not testing generally does not give us that. And testing in a common “QA over the wall” configuration typically does not cut it.
Since I do not know how to so easily produce those results in any other way. TDD becomes the defacto means of implementation for me. That doesn’t mean I should turn a blind eye to new ways of doing things. In lieu of any such information, however, I’ll pick TDD as a starting point. This is still a “how” and not a “what”.
It turns out that for me there are several tangible benefits I’ve personally experienced from practicing TDD:- Increased confidence in the code I produce (even more than when I was simply test infected)
- Less worrying about one-off conditions and edge cases. I’ll get to them and as I think about then, they become tests
- Fun
Fun?
Yes I wrote fun. There are several aspects of this:- I seem to produce demonstrable benefits sooner
- I actually do more analysis throughout
- I get to do more OO programming
Demonstrable Benefits Sooner
Since I focus on one test at a time, I frequently get back to running tests. I’m able to see results sooner. Sure, those results are sometimes disjoint and piecemeal, but over time they organically grow into something useful. I really enjoy teaching a class and moving from a trivial test to a suite a tests that together have caused what students can see is a tangible implementation of something complex.More Analysis
Analysis means to break into constituent parts. When I practice TDD, I think about some end (say a user story or a scenario) then I think about a small part of that overall work and tackle it. In the act of getting to a test, I’m doing enough analysis to figure out at least some of the parts of what I’m trying to do. I’m breaking my goal into a parts, that’s a pretty good demonstration of analysis.More OO
I like polymorphism. I like lots of shallow, but broad hierarchies. I prefer delegation to inheritance. But often, the things I’m writing don’t need a lot of this – or so it might seem.When I try to create a good unit test, much of what I’m doing is trying to figure out how the effect I’m shooting for can be isolated to make the test fast, independent, reliable … To do so, I make heavy use of test doubles. Sometimes I hand-roll them, sometimes I use mocking libraries. I’ve event used AOP frameworks, but not nearly as extensively.
Doing all of this allows me to use polymorphism more often. And that’s fun.
Conclusion
Am I wasting time writing all of these tests? Is my enjoyment of my work an indication that I might be wasting the time of my product owner?Those are good questions. And these are things you might want to ask yourself.
Personally, I’m pretty sure I’m not wasting anyone’s time for several reasons:- The product owner is keeping me focused on things that add value
- Short iterations keep me reigned in
- I’m only doing as much as necessary to get the stories for an iteration implemented
- The tests I’m writing stay passing, run quickly and over time remain (become) maintainable
Even so, since TDD is a how and not a what, I still need to keep asking myself if the work I’m doing is moving us towards a working solution that will be maintainable during its lifetime.
I think it is. What about you?
Excellent observation. I think this is what I’ve had trouble articulating to people who are reluctant to give TDD the time it needs to realize the benefits.
What’s FIRST stand for?
F.I.R.S.T. – A Mnemonic to remember when writing unit tests.
One lesson learned: don’t forget the refactoring!
I’ve repeatedly had to learn not to leave out steps in Test/Code/Refactor.
One reason TDD is fun, or at least more pleasant, is that it’s less stressful. Fewer hard-to-find bugs, fewer nasty surprises.
Very important to keep the reasons in mind, so we do not revert into just doing the moves “of the cult”.
Also, I like the “fun” part – we tend to be better at things we enjoy. For me TDD is also compelling because it gives a good, warm, fuzzy feeling inside. Have thought a lot about why it is so …
[http://dearjunior.blogspot.com/2008/02/psychology-of-tests-testing-and-tdd.html]
“The coverage of your tests will be such that making significant changes will not be too risky”
Seems like it not only does it allow you to understand what can be changed, but it can also be used to definitely identify the risks that are currently acceptable. That means risk assessment based on well written tests are better than any BRDs. A lot of projects are started to determine code risk, exposure, etc and this just provides a tighter bond.
What does SOLID stand for?
Sounds familiar :-)
http://blog.objectmentor.com/articles/2007/08/02/not-a-task-but-an-approach
so waht
great topic. Thanks for your article, its been http://www.china-ouya.com very helpful. Thanks for sharing your information.
????“??”?? ???????????
??20??80??????“??”??21???????
??????“?”???????VI??
???????????????????????????
??????????
That means risk assessment based on well written tests are better than any BRDs. A lot of projects are started to determine code risk, exposure, etc and this just provides a tighter bond. Baby Name Meanings
This looks a lot like the way “good” inheritance should behave.
Doing all of this allows me to use polymorphism more often. And that’s fun.
Thanks for posting such an informative article. I gain more knowledge and information in this article. I will visit your blog to keep updated. gas cards
Very good explanation of what you expect Anyway, I enjoy your blog as I learn a lot viagra
Very interesting and informative article indeed. thanks for posting. http://www.AlliedBuildings.com
Its very awesome article,all the content is so beneficial and valuable for us.Thanks for sharing nice and pretty post. Steel Framed Structure
As the Apple iphone 4 bumper is taken off the marke, will white iphone 4 available soon?
When I try to create a good unit test, much of what I’m doing is trying to figure out how the effect I’m shooting for can be isolated to make the test fast, independent, reliable …
I am really appreacite!
I am really appreacite!
Keep your Contacts and SMS safe! Actually, the contacts and SMS have more values than a cell phone’s own value. You can pay money to buy a new iPhone, but cannot buy your lost contacts and SMS back. So it’s important for you to backup your contacts and SMS in iPhone. And we recommend you backup contacts and SMS regularly. Our backup software can help you take a snapshot for your contacts and SMS. Your important personal information will be never lost.
Sunglasses
hni
That’s a remarkably bold assertion from a Tory PPC from Scotland! Now I know you are an endangered species, but a little perspective is required.
I like this post. A really good one. Thanks guys. roofing venice
thank you for nice information.. I am going to bookmark this page. and i will also suggest my friends about this post.
thanks a lot for it
internette görüntülü olarak okey oyunu oyna, gerçek kisilerle tanis, turnuva heyecanini yasa.
It is really a nice post, it is always great reading such posts, this post is good in regards of both knowledge as well as information. Very fascinating read, thanks for sharing this post here.
I read your article and I really love it Thank you :-)
haha, I love them so much too, they are my treasure xP
Mr Coates coach purses is the longest U.S. market popular with one of the most successful leather brand. Mr Coates coach purses store represents the most admirable American fashion innovative style and traditional skills . Mr Coates coach bags have durable quality and exquisite technology, Conspicuous Coach Heels in the female consumers have good reputation. Welcome to our shop Elegant Coach Purses
Online UK costume and fashion jewellery shop with, Online UK costume and fashion jewellery shop with, Online UK costume and fashion jewellery shop with, Online UK costume and fashion jewellery shop with, Online UK costume and fashion jewellery shop with,
I got these guides very helpful. Here I got much stuff to know..Bounce House Rental
http://www.alijewelry.com/burberry-earring-c-10.html"> Burberry Earring ,
http://www.alijewelry.com/burberry-bangle-c-11.html"> Burberry Bangle ,
http://www.alijewelry.com/bvlgari-earring-c-12.html"> Bvlgari Earring ,
shop with, Online UK costume and fashion jewellery shop with, Online UK costume and fashion jewellery shop with,cheap beats by dre beats by dre store
Thank you for the wonderful article! I want to buy the Jovani dress. Many brides-to-be around me find it difficult to buy a La Femme dress. I think they will be very happy when they read your article.
good in regards of both knowledge as well as information. Very fascinating read, thanks for sharing this post here.beats by dr dre beats by dre sale
it needs a bokmark so i can come back to it later ,nice stuff
There are a couple of carp fishing books I’ve been reading. I’m very interested in that line of books, because I think they write very well, carp anglers, about the general environment. Tom Felton
The professional design make you foot more comfortable. Even more tantalizing,this pattern make your legs look as long as you can,it will make you looked more attractive.Moveover,it has reasonable price.If you are a popular woman,do not miss it.
Technical details of Christian Louboutin Velours Scrunch Suede Boots Coffee:
Fashion, delicate, luxurious Christian louboutins shoes on sale, one of its series is Christian Louboutin Tall Boots, is urbanism collocation. This Christian louboutins shoes design makes people new and refreshing. Red soles shoes is personality, your charm will be wonderful performance.
A university studentbeats by dr dre caught by the enemy, the enemy tied him at the poles,just beats solo headphones purple and then asked him: say, where are you? You do not say it electrocuted! Scheap dr.dre beats studio headphones balck/yellowtudents back to the enemy a word, the result was electrocuted, he said: I am TVU.Hot sale beats by dr dre pro headphones
Get to know about C# and C++. In fact, I find there is no much difference between the two. However, If we want to do much better. I need work hard.
TDD is how I do it, not what I do 46 good post11
TDD is how I do it, not what I do 47 hoo,good article!!I like the post!79
sadsdsdasdasdasdasad
It is a commonly accepted fact in the fashion world that there are three things that make any woman stand out in the crowd?
http://www.outfitscosplay.com/cosplay-catalog/cowboy-bebop-cosplay Deluxe Cowboy Bebop Cosplay Costumes for Sale.Find your favorite characters and cosplay outfits from all the popular anime and games.