Canard
A proof-of-concept of Quack-Driven Development.
Canard is a not-quite-proof-of-concept of Quack-Driven Development (QDD), “a modern Waterfowl Methodology for programmers”. I introduced it in TDD is Canard. Tell it to the Duck, written in response to the “TDD is Dead” debate.
The article takes aim at Uncle Bob’s three rules of TDD, as shown in his Bowling Game Kata: deliberately writing wrong code, like a score function that returns zero, just to watch a test go green. QDD splits tests into two parts instead:
- Validations are written inline with the code and capture requirements, contracts, and the programmer’s intent and beliefs: what you’d say if you were explaining the code to a rubber duck.
- Examples are ordinary specs that set up some state and check that the code transforms it correctly.
In Canard, a validation is a “quack”, written Q< (it’s supposed to look like a duck), that replaces a comment with a testable assertion. Quacks can run before a method, within it or after it returns, and they keep running in production, where they can raise, log, break into the debugger or be ignored. Commented out, they become “dead ducks” that still read as documentation. The repo completes the Bowling Game Kata this way, in Ruby with RSpec.