Home Page :: Story Test-Driven Development of a Floodfill Algorithm

Story Test-Driven Development of a Floodfill Algorithm

This is an experiment with Computer Graphics and the principles of Story Test-Driven Development and Domain-Driven Design. The intent is to have the simplest design possible, which is independent of the graphics library used in the implementation. The benefit is the production of algorithm code that can be coupled with different graphics libraries, like the SWT or Swing.

The motivation behind this implementation was my inability to find a floodfill implementation in either Swing or SWT. If you are working in computer graphics with Java, you might find some of these ideas and implementation useful.

Try the online demo, or download the demo. Run swt.bat or swing.bat, and you should see a map of the United States. Click on any state and you should see it color up.

Take a look at the running storytests that guarantee the correctness of the system.
To make this implementation faster, we could scan rectangles instead of lines. To go about this, we have some failing storytests. The real challenge is in creating the right testing framework that can guarantee correctness. The intuitive and documenting nature of the storytests takes several iterations to evolve, and the intent of this page is to show such storytests.

Take a look at the source code to examine the design.

Click to try online demo

Please direct your feedback to somik at stanford dot edu.