Design Driven Testing: Using tests as specifications of system’s invariants and contracts design
I just got back from JAOO2007. One session of the conference was James Coplien’s “Scrum Architecture”. After this session, a discussion took place about Coplien’s statement that “TDD harms your architecture”! This discussion continued afterwards as an Open Spaces debate. I had the chance then, with the help of Floyd Marinescu, to organize a filmed debate at InfoQ’s studio between Bob Martin and James Coplien on the same topic. I really enjoyed this debate which really showed a high quality spirit of discussion from both sides. Both had their arguments. I will not tell my opinion but rather let you judge yourself once the video is out on www.InfoQ.com .
Recently, I posted about the fact that I always write tests before code, but I don’t do Test Driven Development where I discussed the way I view testing. Yet I don’t guess I’ve been clear enough, so I decided to write few lines trying to better reflect the way I view a testing approach.
When I have a domain problem at hand, first what I think about is partitioning and abstraction, which means dividing the domain into sub-domains. This partitioning procedure is not driven by any tests, but rather by domain knowledge acquired from domain experts. This is extremely important; the architecture/design should reflect the domain/sub-domain problem it is trying to solve. This helps the software be flexible adopting business changes, as it was designed from a business perspective. A book that explains very well this approach is Eric Evans’s Domain Driven Design.
This Up-Front analysis is not defining the full up-front architecture, far from it, rather defining good bases for an architecture that maps to business. It shouldn’t take much time, just enough to help going forward with an iterative approach. This should define, either in code or in a tinny UML sketch, an object structure that forms the basic sub-domain’s components.
After defining the main structure of the sub-domain’s solution, I follow an iterative process as follows:
1: Driven by the business knowledge crunching, I define a component’s contract with its invariants and conditions
2: I write a test that forms the specification of this contract and its invariants
3: I start the implementation to satisfy the specifications I defined in the test
A very important note here is that the contract specifications should be readable, very clear and explicit. This explicitness helps to have a better vision of the whole system while reading the contracts-invariants of its defined components. This also helps spot bugs without the painful debugging: this approach of Design by Contract reflects developers understanding of the business domain in a more explicit way, so it makes it easier to spot misjudgments developers might have done in their implementation. This intention revealing method of development highlights important business rules, rather than letting them hidden behind an abstraction. Abstractions should not hide any important business concern as an implementation details. Explicit contracts and invariants allow business experts to have a look on what is going on inside the software. For an example of bugs that result from developer’s misjudgment see Reganwald’s recent post .
Of course unit tests are not the best tools for this approach. They work fine if we emphasize on methods and class naming for readability and visibility of invariants and rules. Still I prefer tools like BDD or Eiffel/Spec# Design by Contract. Hope we will have some more support for such tools in the industry soon.
A metaphor James Coplien used to illustrate the problem in Test Driven Development approach, which made sense to me, is a test driven course in a school. It’s about a teacher that finds that most of his students fail in the final test. So to make things work better, he decided to ask the students to write themselves their tests by the beginning of the semester, and then to let them pass these tests by the end of that semester! Hence, they might get better grades, but that doesn’t mean they got better knowledge at all.
September 24, 2007
Charles Simonyi reveals production use of Intentional Software @ JAOO
Floyd Marinescu did a good summary of Simonyi’s presentation on JAOO and posted it on IinfoQ
http://www.infoq.com/news/2007/09/intentional-at-jaoo
It seems that guys at Intentional software are having something that works seriously, in real world business.
September 22, 2007
I always write tests before code, but I don’t do Test Driven Development
I am not driven by tests, my code neither. Actually my code is rather driven by design. I do use a test first approach, but I use for a contract first discipline in order to test that my decoupling works. Yes, I think about decoupling first, and then I write tests. I design, and then I write tests. Of course I don’t take a lot of time in my design reflection. But I am not driven by any force other than my experience and the context at hand. I do abstractions and I validate them with tests. Actually, I use test first approach to specify my design. I don’t write any piece of code without a failed test waiting for it, but still I prefer to call that a test-first approach than the confusing “test-driven development”!
More about this approach to testing in my newer post Design Driven Testing: Using tests as specifications of system’s invariants and contracts design…
September 20, 2007
I will be talking about Language-Oriented-Programming at ValtechDays 2007

I will be talking at ValtechDays 2007 about one of my favorite topics, Language Oriented Programming and DSLs. I am not claiming to be inventing anything there. All that I am trying to do is to help adopting ideas that can have a return on software maturity and help bridging a gap between developers and business people. Well my favorite topics are multi-paradigm programming language and also patterns of DSL, but I don’t have yet enough arguments to introduce it in my talk. Maybe in next ValtechDays or QCon, in case my ideas get more mature and my research gets more advanced.
My schedule for JAOO 2007
It is always a hard choice for such an interesting conference, I scheduled my first day, still couldn’t decide about some session. I’ll be trying to make some sort of live coverage with my laptop
as I did for QCon2007
| Wednesday | Architecture Quality (day 2) | Enterprise Application Frameworks (day 2) | Professional Developer | Public Sector Open Source | Scrum at JAOO: Case Studies | Scrum: Open Space Discussions | Solution Track: Wednesday |
| Host | Frank Buschmann | Erik Doernenburg | Bob Martin | Mogens Kühn Pedersen | TBA | Facilitator: Diana Larsen & Jens Østergaard | |
| 09:00 - 09:15 | Introduction: Architecture Quality (day2) Track host: Frank Buschmann Location: Conference Hall |
Introduction: Enterprise Application Frameworks (day 2) Track host: Erik Dörnenburg Location: SAS Nortvegia |
Introduction: Professional Developer Track host: Robert C. Martin Location: Conference Hall 3 |
Introduction: Public Sector Open Source Mogens Kühn Pedersen Location: SAS Dania |
Introduction: Case Studies Speakers: TBA Location: Conference Hall 2 |
Introduction: Open Space Speakers: TBA | |
| 09:15 - 09:30 | Break | ||||||
| 09:30 - 10:30 | Operational Scalability in the Next-Gen-Web World Wayne Fenton Location: Conference Hall |
MonoRail: Building Maintainable & Testable Web Applications Hamilton Verissimo & Oren Eini Location: SAS Nortvegia |
With Economy and Elegance Kevlin Henney Location: Conference Hall 3 |
Developing and Sustaining Local Authority Applications through Aingaran Pillai Location: SAS Dania |
Scrum@Planon Erik Jaspers & Maarten Smeets Location: Conference Hall 2 |
Open Space (1) Speakers: TBA | ServiceMix 4.0, the next generation ESB Guillaume Nodet |
| 10:30 - 11:00 | Break | ||||||
| 11:00 - 12:00 | Fault Tolerance Robert S. Hanmer Location: Conference Hall |
Choosing the right technology for the web-tier Alef Arendsen Location: SAS Nortvegia |
The Journeyman’s Tale Laurent Bossavit Location: Conference Hall 3 |
OSS Electronic Health Care Records; Vista in Denmark Martin Sølvkjær Location: SAS Dania |
Scrum@Telenor Peter Johansson & Arne Ahlander Location: Conference Hall 2 |
Open Space (2) Speakers: TBA | Infragistics Speakers: TBA |
| 12:00 - 13:00 | Lunch | ||||||
| 13:00 - 14:00 | Performance Art Kevlin Henney Location: Conference Hall |
Ruby on Rails - ActionPack Justin Gehtland Location: SAS Nortvegia | |||||
