So on a reading trip about testing, I read about how certain parts of the aerospace industry practice TDD on the order of 4-to-1. Meaning 4 tests for every part of the system.
This got me thinking. We should start using Comment Driven Development*. How many lines of comment could we get in for each line of code. Just imagine how clear our code would be.
Example
Take this example:
jonny.go_to_store
Now, sure that is clear, but it could be better. Here it is with 100% CDD Coverage:
#Send jonny to the store
jonny.go_to_store
Even better is 200% CDD Coverage:
#Send jonny to the store, three blocks north and one block tothe left.
#he should get eggs, bacon and milk while he is there.
jonny.go_to_store.
But we can still do better:
#Jonny's mother has asked him to go to the store to get eggs, bacon and milk.
#She has given him money and he is getting ready to go. He grabs his coat (it's -13 F)
#and starts walking. To get to the store he heads three blocks north, turns left at the
#corner and walks one more block. Bacon is in the back with meat. Eggs and milk are on
#aisle 23. It should cost $9.67.
jonny.go_to_store
Now that's something we can all strive for. 500% CDD Coverage. I know that numbers like these will impress bosses everywhere, unless they are related to PHB.
Explanation
This is really just the natural evolution of TDD and BDD. It is simply another way to make the code more readable and more maintainable. Besides, who can argue with 500% coverage?
So get out there and start massaging your codebase. It’s time for the change, and it’s time to start commenting!
*If you couldn’t figure out by here that the sarcasm tags were on overdrive, then please seek help. Lack of sarcastic understanding is a serious disorder that needs to be addressed by a proffesional. Preferably, a sarcastic one.
Post a Comment