📄 spikesolution.html
字号:
<head><title>Spike Solution</title></head><body><h1><img src="logo.gif"> Spike Solution</h1>Now described in Alistair's medical format in <a href="http://c2.com/cgi/wiki?SpikeDescribed">SpikeDescribed</a>.
<p><hr>
<p>I would often ask Kent, "What is the simplest thing we can program that will convince us we are on the right track?" Such stepping outside the difficulties at hand often led us to simpler and more compelling solutions. Kent dubbed this a <em>Spike</em>. I found the practice particularly useful while maintaining large frameworks.
<p><em><a href="http://c2.com/cgi/wiki?AnswerMe">AnswerMe</a>: <a href="http://c2.com/cgi/wiki?WhereDidSpikeSolutionComeFrom">WhereDidSpikeSolutionComeFrom</a>?</em>
<p>I've mentioned that it is to be a part of Episodes-II when ever that gets written. The following pattern is from my overhead slide of the same name ...
<p><UL><li> Compounded complexity within existing code can distract from the essence of a requirement. <strong>Therefore</strong>, Write the smallest possible code that could be said to perform a function independent of existing mechanism.
<p></UL><a href="RonJeffries.html">RonJeffries</a> tells me that he has an elaboration of this in the works too. There, now we are both on the hook. -- <a href="http://c2.com/cgi/wiki?WardCunningham">WardCunningham</a>
<p><hr>
<p>A micro example of this occurred at OOPSLA 97 at Ward's and my <a href="PairProgramming.html">PairProgramming</a> BoF. Someone asked us to implement accounts and transactions in less than five minutes. Here is the code for our first spike:
<PRE> #(10 -5 -2) inject: 0 into: [:s :e | s + e]
</PRE>The final balance of this account is, of course, 3. Our user then added the requirement that the transactions be dated. The new spike looked like this:
<PRE> t := #((10 0) (-5 3) (-2 7)).
(t select: [:e | e last < 5]) inject: 0 into: [:s :e | s + e first]
<p></PRE>The point with this spike is that we were able to explore (learn about) the crux of the problem- the combination of selection and summing- without invoking any of the impedimentia of objects.
<p>Spikes are good when you are knowledge-limited, not time-limited.
-- <a href="KentBeck.html">KentBeck</a>
<p><hr>
<p>... and I am really sorry I did not see <a href="SpikeSolution.html">SpikeSolution</a> in time to ask you for a copy to put into the appendix of my book with the other knowledge-based project management patterns. It is a perfect complement to <a href="http://c2.com/cgi/wiki?ClearTheFog">ClearTheFog</a>, EarlyAndRegularDelivery<a href="http://c2.com/cgi/wiki?edit=EarlyAndRegularDelivery">?</a>, ProtoType<a href="http://c2.com/cgi/wiki?edit=ProtoType">?</a>, and <a href="http://c2.com/cgi/wiki?MicroCosm">MicroCosm</a>, illustrating something none of those do. <a href="SpikeSolution.html">SpikeSolution</a> is a cross between EarlyAndRegularDelivery<a href="http://c2.com/cgi/wiki?edit=EarlyAndRegularDelivery">?</a> (deliver increments continuously to get feedback on the process) and ProtoType<a href="http://c2.com/cgi/wiki?edit=ProtoType">?</a> (codify subset of best current understanding to shed light on the problem or solution), and much shorter in duration than anything I suggested. I cite <a href="SpikeSolution.html">SpikeSolution</a> to many people these days as the shortest initial 'V' in a VwStaging<a href="http://c2.com/cgi/wiki?edit=VwStaging">?</a> policy (where a V is either a prototype or a deliverable increment).
<p><hr>
<p>On the Chrysler C3 project, the way we use <a href="SpikeSolution.html">SpikeSolution</a>, in the context of Alistair's patterns, is as a tiny version of <a href="http://c2.com/cgi/wiki?ClearTheFog">ClearTheFog</a>. We like a <a href="SpikeSolution.html">SpikeSolution</a> to take no more than a couple of days, and a half day is ideal. We plan to throw away the code, although sometimes something is salvaged.
<p>Sometimes we might use a Spike to learn about the algorithm, as with the accounts example Kent gives above. Those should take minutes in most cases, not hours.
<p>Usually, however, we'll go deeper, using the real objects, and broader, typically from reading the real input to writing the real output. We found that when we didn't consider the full breadth, we got into trouble, so we changed our process accordingly.
-- <a href="RonJeffries.html">RonJeffries</a>
<p><hr>
<p>One more thing ... there's a special kind of discovery that goes with the kind of <a href="SpikeSolution.html">SpikeSolution</a> Kent shows above. This approach goes to the core algorithm, and shows you the shape that the final solution would like to have. Here we see that we'd like the collection of accounts to have real Collection behavior, selection and injection.
<p>When we focus on this "inner loop", it seems to me that we are exploring some essential reality of the problem and its natural solution. We can focus the outer parts of the solution (the input and the output, for example) to bring us the objects that are just right for making the core algorithm clear, simple, and efficient.
<p>This sounds weird and vague even to me, but I know there's an idea in here somewhere. Fix it for me?
-- <a href="RonJeffries.html">RonJeffries</a>
<p><hr>
<p>If I said "transform-centered design", would you hit me? What I hear you saying is "Write the middle first". After you understand the middle, you know the preconditions and postconditions necessary to support it.
-- <a href="http://c2.com/cgi/wiki?BetsyHanesPerry">BetsyHanesPerry</a>
<p><hr>
<a href="RonJeffries.html">RonJeffries</a>' comments remind me of Fred Brooks' directive to "Write one to throw away", in <a href="http://c2.com/cgi/wiki?MythicalManMonth">MythicalManMonth</a>.
-- <a href="http://c2.com/cgi/wiki?KatyMulvey">KatyMulvey</a>
<p>Don't look broke to me. It does remind me of <a href="http://c2.com/cgi/wiki?DijkstraAndRefrigerators">DijkstraAndRefrigerators</a>. ps. I just took a crack at describing it in my medical pattern form in <a href="http://c2.com/cgi/wiki?SpikeDescribed">SpikeDescribed</a>. -- <a href="http://c2.com/cgi/wiki?AlistairCockburn">AlistairCockburn</a>
<p>Perhaps not <em>broke</em>, but the essence of "write one to throw away", to me, is that you learn something from your first attempt to write something. This pattern says the same thing, with the constraint that you keep your first attempt small and simple, so you can learn something new quickly.
--<a href="http://c2.com/cgi/wiki?KatyMulvey">KatyMulvey</a>
<p><hr>
This reminds me of a standard technique for learning a new programming language (see <a href="http://c2.com/cgi/wiki?HelloWorld">HelloWorld</a>) or testing the actual effect of some command or language construct.
<p>Create the shortest possible procedure (or object and method) that exercises the command (containing only command, output, and life-support). Compile, run (possibly in the debugger), and modify until understanding comes.
<p>Although this should be obvious, sometimes I forget and instead wade through huge chunks of code in the debugger.
--<a href="http://c2.com/cgi/wiki?WayneCarson">WayneCarson</a>
<p><hr>
If we regard a <a href="SpikeSolution.html">SpikeSolution</a> as research, there's a quote from <a href="http://c2.com/cgi/wiki?RogerNeedham">RogerNeedham</a> on the lines of
<em>Production development is done with tweezers, research is done with a shovel</em>
<p>--<a href="http://c2.com/cgi/wiki?SteveFreeman">SteveFreeman</a>
<p><hr>
<p>I've put my experience with <a href="SpikeSolution.html">SpikeSolution</a>(s) on the ATS project in <a href="http://c2.com/cgi/wiki?AtsSpikeSolution">AtsSpikeSolution</a>. --<a href="http://c2.com/cgi/wiki?JimLittle">JimLittle</a>
<hr>
<p>I hope XP authors will write <a href="SpikeSolution.html">SpikeSolution</a> uses into future XP books. I have had a very enlightening experience with a <a href="SpikeSolution.html">SpikeSolution</a>. My experience and recommendations are at <a href="http://c2.com/cgi/wiki?SpikeAsDesignAid">SpikeAsDesignAid</a>. --BretWilliams<a href="http://c2.com/cgi/wiki?edit=BretWilliams">?</a>
<p><hr>
<em>We choose to write this code first, not because it is easy, but because it is hard.</em> --<a href="http://c2.com/cgi/wiki?JohnFitzgeraldKennedy">JohnFitzgeraldKennedy</a>
<p><hr>
<a href="http://c2.com/cgi/wiki?TopicGlossaryXp">TopicGlossaryXp</a><hr><a href="http://c2.com/cgi/wiki?edit=SpikeSolution">EditText</a> of this page (last edited March 9, 2001)<br><a href="http://c2.com/cgi/wiki?FindPage&value=SpikeSolution">FindPage</a> by browsing or searching<p><font color=gray size=-1>This page mirrored in <a href="index.html">ExtremeProgrammingRoadmap</a> as of March 31, 2001</font></body>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -