SPA Conference session: More Bells and Whistles: Beyond TDD with Functional Programming

One-line description: Exploring validation and verification of code from an agile perspective with more than unit tests, or how can we improve quality, simplicity, legibility using tools from the functional programming pa
 
Session format: Workshop (150 mins) [read about the different session types]
 
Abstract:Test Driven Development is one cornerstone of eXtreme Programming and
its advantages are well-known: it guides developers, builds confidence
in the system and provides secure scaffolding to support change.
There are however some drawbacks in using this technique: it is quite
verbose, it places to much emphasis on details, on the 'how' instead of
the 'what', it produces more code that will need to be maintained and
is not very useful to non technical people.

In this session, we want to explore techniques that keep the spirit of
TDD while being more concise, provides a better abstract view of what
we want to achieve, and may sometimes be more legible. These
techniques are drawn from the functional programming languages tools
and techniques. Functional languages are getting more and more
attention and some of their characteristics may be useful in
increasing software quality.

This workshop will be a hands-on guided coding party using the pure,
lazy, statically typed language Haskell and providing introduction to
some tools and techniques. Examples in other languages (Java, Scala, Javascript) will also be
provided.

Its goal is to study and assess each of the following techniques and tools within
the framework of XP practices in order to go *beyond* standard code
quality improvement practices:
- property-driven test generation with Quickcheck (http://www.cs.chalmers.se/~rjmh/QuickCheck/) and coverage
assessment with hpc;
- algebraic datatypes, type classes and polymorphism and how an
advanced type system can improves the static safety of
programs;
- simple equational reasoning or how to prove that one's functions
work as expected, within some expected bounds.
 
Audience background: - deep interest for programming languages and coding practice: most
of the workshop's time is dedicated to coding and exploration of
languages,
- interest for agile practices, more precisely XP coding practices
and for improving one's own practices,
- previous exposure to some functional programming language or, even
better, Haskell definitely a plus.
 
Benefits of participating: - practical working on FP techniques and tools
- FP are hype (sort of): What benefits could their use really
provides in terms of quality ? communication ? simplicity ?
feedback ?
- Understanding sophisticated (ML style) type system and what are
they useful for
- Making things more abstract sometimes make them more simple
 
Materials provided: - source repository for programming examples and exercises, needed software
- source of sessions material: extended software examples, more
coding examples, documentation and references
- Haskell cheat sheet and development environment setup guidelines
- Session's summary handouts
 
Process: 1. a "simple" yet realistic problem is presented: how to manage form/input validations in a uniform and legible way ?
2. a solution is sketched in Haskell and needed infrastructure and
process are set up,
3. various kind of development techniques made possible with Haskell
are introduced, explained and tried on this example, using part of
the larger problem as motivation:
1. TDD using property-based test case generation with QuickCheck,
2. Proper composition of validations and definition of an
expressive embedded DSL using (and abusing) the type system,
3. proof of simple properties and complexity measures using
formal reasoning on equations,
4. applicability of each of this technique is assessed wrt to
mainstream agile development practices
 
Detailed timetable: - 0-20': Introduction and form validation problem (20')
- 20-30' : Process negotiation (10')
- all coding shall be done in *Randori* mode as in an XP dojo:
coding is done in pairs, with 5' slots, pilot of pair is
replaced by copilot and new copilot replace the latter each slot,
- participants can bring along their own laptop, a Mercurial
repository will be shared
- guidelines for setting up development environment will be
provided
- 30-65' : First problem: using Quickcheck to define "high-level tests" (35')
- 5' : introduction to quickcheck and the problem
- 30': coding rounds
- 65-100' :Second problem: advanced properties of the type system for static
validation of expressions (35')
- same format as first problem
- 100-135' : Third problem: equational reasoning and complexity analysis with
pure functions (35')
- same format as first problem
- 135-150' : Wrap-up, evaluation and conclusion (15')

 
Outputs: - the code produced during the session as a versionned repository
- evaluation of the three techniques presented: applicability to
mainstream development, links to other languages support
- web site with all the above
 
History:I designed with Christophe
Thibaut an introductory session on functional programming languages which has been presented at XP Day Paris and Agile 2008, and will be presented at XP Days Benelux 2008. This session is a creation that draws upon our experience on this theme, exploring more advanced topics.
 
Presenters
1. Arnaud Bailly
OQube
2. Christophe Thibaut
OCTO Technology
3.