⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 askthecode.html

📁 极限编程 Extream Programing
💻 HTML
字号:
<head><title>Ask The Code</title></head><body><h1><img src="logo.gif"> Ask The Code</h1>Context:
<p>There's something you don't understand about your code. (Typically you don't understand its behavior ... it's doing what you told it, but not what you want.-) You can try to match your mental model of the code to the code itself, but you may fail, or you may fail to do it quickly.
<p><strong>Therefore:</strong>
<p>Ask the code. Set a breakpoint and find what the value really is. Set a breakpoint (or two) and find what the flow of control really is. Set a breakpoint and find how (and if!) the program gets somewhere. Maybe don't set a breakpoint, just type some code into your debugger and run it.
<p>Known uses:
<p><a href="ExtremeProgramming.html">ExtremeProgramming</a> in the <a href="http://c2.com/cgi/wiki?ChryslerComprehensiveCompensation">ChryslerComprehensiveCompensation</a> project.
See
<a href="http://www.XProgramming.com/Practices/PracLetSmalltalkTellYou.html">http://www.XProgramming.com/Practices/PracLetSmalltalkTellYou.html</a>
and
<a href="http://www.XProgramming.com/Practices/PracJustSetTheHalt.html">http://www.XProgramming.com/Practices/PracJustSetTheHalt.html</a>
<p><hr>
<p>Also Known As:
<p>&quot;Star Wars Consult&quot; and &quot;The Jedi Way&quot;
(in the immortal words of Obi-Wan Kenobi: <em>&quot;Use the Source Luke!&quot;</em>)
<p>-- <a href="http://c2.com/cgi/wiki?BradAppleton">BradAppleton</a>
<p><hr>
<p>I've been applying this to my own work in Perl and C++.
(It's easier in Perl, where the containers are more visible to the debugger,
and I can type more code in the debugger).
<p>Heh. I just spent an hour trying to ask the [C++] code, &quot;How is this variable initialized?&quot; I just realized; the code's inability to answer ... was an answer. (The variable needed to be zero, and had been; until I changed from a global variable, where all fields are guaranteed to start as zero, to a dynamically allocated variable, where they aren't.)
<p>At that point, the student achieved enlightenment.-)  --<a href="http://c2.com/cgi/wiki?PaulChisholm">PaulChisholm</a>
<p><hr>
<p>Also related to <a href="http://c2.com/cgi/wiki?DebuggingAndTheScientificMethod">DebuggingAndTheScientificMethod</a>.  As Donald E. Knuth <em>(<a href="http://c2.com/cgi/wiki?DonKnuth">DonKnuth</a>)</em>
supposedly once said:
<p><em>Beware of bugs in the above code; I have only proved it correct, not tried it.</em>
<p>--<a href="http://c2.com/cgi/wiki?ScottJohnston">ScottJohnston</a>
<p><em>I was curious about this and looked on Knuth's web page. He writes [<a href="http://www-cs-staff.stanford.edu/~uno/news98.html">http://www-cs-staff.stanford.edu/~uno/news98.html</a>]: &quot;More than a hundred webpages ascribe that quote to me, and it sounds like something I might well have said. But lately people have been asking me for the authentic source, and I've totally forgotten where I wrote it. Probably not in a published paper, since I've written few papers in the first person that include untried code. My best guess is that it was in a letter I sent to somebody. So if you were that somebody, or if you have any other clues about the source of that line, please let me know.&quot;</em>
<p>He got an answer: see <a href="http://www-cs-staff.stanford.edu/~knuth/faq.html">http://www-cs-staff.stanford.edu/~knuth/faq.html</a>. --<a href="http://c2.com/cgi/wiki?DanSchmidt">DanSchmidt</a>
<p><hr>
<p>This principle applies outside of software, too.  In <a href="http://c2.com/cgi/wiki?HowBuildingsLearn">HowBuildingsLearn</a>,
<a href="http://c2.com/cgi/wiki?StewartBrand">StewartBrand</a> quotes an MIT animal physiologist who told his students:
<p>The animal is always right.  When in doubt, ask the animal.
<p>-- <a href="http://c2.com/cgi/wiki?EugeneWallingford">EugeneWallingford</a>
<p><hr>
<a href="http://c2.com/cgi/wiki?CategoryQuote">CategoryQuote</a><hr><a href="http://c2.com/cgi/wiki?edit=AskTheCode">EditText</a> of this page (last edited February 1, 2001)<br><a href="http://c2.com/cgi/wiki?FindPage&value=AskTheCode">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 + -