Designing a Framework with Test-Driven Development: A Journey

Author(s): Eduardo Guerra
Venue: International Conference on Software Testing
Date: 2013

Type of Experiement: Case Study
Sample Size: 1
Class/Experience Level: Professional
Data Collection Method: Code Metric

Quality
4

A developer uses test driven development (TDD) to develop an open source framework called Esfinge QueryBuilder. Although TDD can be used for typical application development, the challenge for the developer was to use it to develop an extensible framework that uses reflection and interprets annotations as well as provide the same functionality independent of the persistence paradigm used, providing a hotspot to plug in query generators for different kinds of databases.
The development of Esfinge QueryBuilder is analyzed over five versions. Various metrics were measured to compare and contrast the test code with the framework code. The computed proportions varied little through the versions, indicating that coding standards were maintained as the framework evolved using TDD. It was observed that over the course of development that the classes were well distributed and the code’s stability over time is one of the benefits of using TDD. This idea of keeping the code clean was reinforced by TDD. It was reinforced by continuously creating the simplest solution that makes the current test suite pass.
Unfortunately big refactorings are inevitable when you follow a TDD philosophy in a complex set of classes. But the developer explains how reworks are not a consequence of a design mistake but as a natural part of design when using TDD. It is also important that the design is expressed through the tests, and the developer should know what he or she wants to create and how they want to implement it using already known design patterns. You cannot rely on TDD to provide a design pattern through the constant writing of new tests.
In conclusion the knowledge of design patterns and refactoring techniques is essential to drive code to a good design solution, especially when using TDD. Unit tests help define a single purpose for classes, enabling a good division of responsibility. Additionally, because tests provide a vision from the client code’s perspective, some design flaws are easy to detect.

0