Member-only story
Test-Driven vs REPL-Driven Development
Reflections on the advantages of a TDD and REPL based approach to software development
Few things gets software developers as passionate as discussions about best engineering practices. Should you do test-driven development, behavior driven development or even REPL driven development?
While I am quite opinionated on software development, I don’t want to claim there is one right true path. The style of development that will work best for you depends both on your traits, the language you use and the problem you are trying to solve.
Here I will try to make the case for REPL-driven development over TDD, based on my experiences. I will like to build up my case around a made up example, a nonsense function to assemble some parts into a larger whole:
function assemble(t::Thingy, d::Doodad, s::Stuff)
bolts = get_bolts(HEX, 4)
goo = get_glue(SUPER)
gizmo = put_together(flip(t), s, bolts)
tighten!(gizmo)
doohickey = glue(gizmo, d, goo)
dry!(doohickey) if isfaulty(doohickey)
throw(AssemblyFailed("Faulty parts, buy new ones!")
end return doohickey
end
We imagine that this is the correct function implementation. It is the goal of our development efforts. At the end we should have a finished assembled doohickey
object which we can return to the caller of the assemble
function.
But as with any software development, you don’t know the types, objects and problem very well when you start. You may have misunderstood the API you are using. Let us imagine that your initial coding attempt looks something like this:
function assemble(t::Thingy, d::Doodad, s::Stuff)
bolts = get_bolts(FLANGED, 10)
goo = get_glue(EXPOXY) gizmo = glue(t, s, goo) # wrong assumption on input/output
dry!(gizmo) doohickey = put_together(gizmo, d, bolts)
tighten!(doohickey) return doohickey
end
You have gotten the types of bolts to use, and the type of glue wrong. Also you are gluing together stuff which should have been screwed together with bolts and visa…