From: Andrew Johnson Date: 2006-03-26T00:33:53+09:00 Subject: Re: Newby Maze solution On Sat, 25 Mar 2006 22:32:16 +0900, Jim Weirich wrote: Jim writes: > The secret to TDD is learning to let the tests drive the code. And that's true of course, but it isn't the real secret... Jim later tells us: > The key is to work with little bits of functionality at a time, so the > problem is never too hard all at once. And that's true of course, but it isn't the real secret... Jim then writes: > I would start off with the goal of writing a maze solver that can solve > really trivial mazes. [ substitute "problem X" for "maze" for generality ] And now we begin to close in on the real secret ... Jim follows with: > For example, my first four tests would probably have it solve the following > four one step mazes: > > #### ### #### ### > #se# #s# #es# #e# > #### #e# #### #s# > ### ### And suddenly we have a trivial reduction of the problem that makes all that follows simply seem a natural process. Once you see it, it even feels trivial and obvious --- but don't kid yourself! What Jim makes look so easy is no trivial task (and, of course, isn't limited to TDD). It is all too easy to slip into to thinking about the Solution Space too early in the game: "What's the simplest, most naive maze solving approach I can think of ... ", -- and of course, trying to write tests for a naive maze solver is as hard as trying to write tests for a very clever maze solver (and doesn't help us do TDD because we are thinking in the wrong Space). Jim focuses on the Problem Space: "What's the simplest, most naive maze I can think of ...", and in one fell swoop he reduces the Problem Space to just a step (or two) above the Null Problem Space, something that can serve as a minimal test, and with a clear path of growing complexity. And so at last we have uncovered the real secret to TDD ... getting Jim to look at your Problem Space. cheers, andrew -- Andrew L. Johnson http://www.siaris.net/ What have you done to the cat? It looks half-dead. -- Schroedinger's wife